Training SpamAssassin on Snow Leopard Server

Training SpamAssassin on Snow Leopard Server

Yesterday I wrote about how to use public mailboxes with Mac OS X Servers built-in Mailserver, Dovecot. Today I want to take it a little bit further and tell how to enable training for SpamAssassin:

SpamAssassin is included with Mac OS X Server 10.6 Snow Leopard. It is is quite powerful and has a lot of features. As with many other parts of the server OS, Apple decided to expose only very little to the GUI, making it easy to understand and set up. Experienced admins might want to tweak more and access additional features. One could be the training capabilities of SpamAssassin: We can set up two mailboxes to train SpamAssassin, one containing SPAM, one containing HAM (the opposite of SPAM). There are several ways to do this. My way to set it up is just the way I liked it and maybe you might want to do it differently, but my description here can give you a clue on how to start.

Step 1) We use Workgroup Manager to create and set up mail for two users, one named „junkmail“ and one named „notjunkmail“, using IMAP. We then set up on a client to access those mailaccounts. With this, the mailboxes on the server actually get created and we can also use later to test and troubleshoot.

Step 2) We download and install the free spamtrainer script from on our server. When installed, try running spamtrainer on the command line just by typing:


You should see it working. If there are any errors, you should try to fix them. If you skipped Step 1, the mailboxes have not been created yet and so spamtrainer won’t work. spamtrainer expects mailboxes for the users „junkmail“ and „notjunkmail“

You can make spamtrainer run periodically by invoking

spamtrainer -i

and answering the questions when to run it. Spamtrainer will then create an entry in your crontab. The crontabs are located in /usr/lib/cron/tabs and launchd executes them.

If you are happy with sending all your spam to the „junkmail“ user and ham for learning to the „notjunkmail“ user, you are pretty much done here. To have it a litte bit more comfortable, you can go a bit further:

Step 3) Set up two shared mailboxes, named „junkmail“ and „notjunkmail“ in a public folder. I have explained this yesterday:

Step 4) Replace the private mailboxes for the junkmail and notjunkmail user with the shared ones:

cd /var/spool/imap/dovecot/mail/

Then identify the mailbox for the junkmail user. When you

ls -la

look for a line like this:

drwx——  15 junkmail     mail   510 May  4 19:37 6C40D471-C6D4-432C-A52D-3E24C0E2DC06

The end of the line, here „6C40D….“, it is the UUID of your junkmail user and will be different for you.

Note your UUID. Then you might delete the mailbox or – as I prefer – just rename it:

mv 6C40D471-C6D4-432C-A52D-3E24C0E2DC06 6C40D471-C6D4-432C-A52D-3E24C0E2DC06_old

Now we create a symbolic link to the shared junkmail folder:

ln -s /public/.junkmail 6C40D471-C6D4-432C-A52D-3E24C0E2DC06

Then repeat this for the „notjunkmail“ user and its mailbox

Step 5) Let you users subscribe to the two public mailfolders „junkmail“ and „notjunkmail“. They can then move mail from their own mailboxes there to train spamassasin.

No Comments

Sorry, the comment form is closed at this time.