SpamAssassin, Amavis and ubuntu

If running spamassassin (SA) with amavis without usage of spamd on ubuntu 10.04 and you feel that sa-learn isn't working right, here are a few tips.

I had mails that were false positive and I had to dig a little more than usual to get it working.

learning

Think that SA is executed by amavis user, so:

sudo -u amavis -H sa-learn --showdots {--ham|--spam} YOUR_MAIL_OR_MBOX_OR_MAILDIR

The trick is the sudo part, sa-learn docs can be found everywhere on the net.

checking

This is how to check how spamassassin will rate your mail:

cat badmail | sudo -u amavis -H spamassassin -t

Which is very usefull when used with the same mail, before and after learning.

statistics

Looking at statistics can be usefull to check that the number of spam and ham are consistent with your learning sessions:

sudo -u amavis -H sa-learn --dump magic | grep am

Note

Do not forget to restart amavis with /etc/init.d/amavis restart.