Configuring SpamAssassin for Evolution 1.4 on FreeBSD
Filtering junk mail with SpamAssassin and Evolution on FreeBSD
Installing SpamAssassin
SpamAssassin is in the ports tree
mail/p5-Mail-SpamAssassin/
Install it as you would any normal port.
Setting up SpamAssassin
It will already work by default. SpamAssassin works as a standalone script, or as a client/server. On multiuser systems, and for heavier use it is recommended to run the server spamd, and access it with spamc. In this article, we will set it up as client/server
spamd - SpamAssassin daemon
To load the daemon, simply copy or rename it spamd.sh, this will make it load automatically next time you restart your computer.
To load it manually:
/usr/local/etc/rc.d/spamd.sh
That's it, for a basic setup.
Setting up Evolution filters
From your Evolution menu (when using Mail folder) Select the Filter option from the Tools menu.
You then should click on Add button to create a new filter.
The add filter dialog should come up. I've called my filter spamassassin.
What our filter is going to do, is pipe incoming email to spamassassin client (spamc), which would then check if the email is spam[1] or not.
- Add a shell command, for the filter, click on Sender and change it to Pipe to Shell Command. In the input box, enter spamc -c.
- spamc returns 0, if it's not spam and an error code if it is. So we will
set the returns drop down menu, to does not return and the value 0.
Now any mail that SpamAssassin thinks is spam, will be detected by this filter.
- After it is detected, we would want it to be moved to a spam or junk folder. If you don't have one, you should create one. You could delete it automatically, but sometimes SpamAssassin gets it wrong, and none junk emails might be deleted accidentally. (more on how to make it accurate later).
- After we have moved it, we would want the filter to stop processing. So add another, action and select Stop Processing.
That's it, now we have an advanced junk mail filter, and here is how it should look like.
What you can do, is now move the SpamAssassin filter, in the order, you want it run. Priority, runs from top to bottom. Having it at the top, means it will check emails for spam, before any other filters.
Training SpamAssassin's Bayesian Filters
Training SpamAssassin
Although SpamAssassin has some default rules that catch a lot of spam emails, it is not perfect. Sometimes legitimate emails can be flagged as spam. In order to avoid this, we make it "smarter" by training it with emails that we think of as spam, and emails that we think of as ham[2]. As you train it with more emails, it becomes more and more accurate.
Training for spam
Remember earlier, that we moved all junk emails to a spam folder?
You should also move any spam emails that SpamAssassin misses into that folder too.
Training spamassassin for spam is quite easy. Open a terminal and go to your evolution mail folder.
~/evolution/mail/local
To train SpamAssassin to learn which emails are spam, we issue this command (where Spam is the name of your spam folder).:
sa-learn --mbox --spam Spam
Training ham
Is similar to the above, except that you point it to a folder that contains legit emails. Your Inbox usually contains a good variety of legit emails from which to learn from:
sa-learn --mbox --ham Inbox
Train it often
You should train SpamAssassin often, because not only will you get a variety of good emails, but spammers often change tactics, and there always LookOut (Outlook) users, itching to send the latest viruses your way.
Evolution 2.x
Evolution now features integrated junk email handling. It will use SpamAssassin to handle it, so that means you will not need to retrain spam emails when you upgrade.
It also features integrated training, so you know longer have to train it manually and you can mark emails as either junk or not junk from Evolution itself.
Footnotes
[1] spam is cheap canned pork, and used to define junk or unwanted emails
[2] ham is high quality pork meat, and is used to define good emails



