![]() This page is part of the EmailServer article. SpamAssassinSpamassassin is a very versatile and complete spam fighting solution. It uses statistical techniques as well as external blacklist and can be configured to use add-on tools to make its detection more refined. SpamAssassin uses a rating system whereby each email goes through a list of tests and the mail is flagged for every positive test, increasing the number of spam points it is allocated. Each test allocates a variable number points or fraction of a points depending on how useful and reliable it is at detecting spam. Once the email has gone through all the tests have been performed an action is taken based on the total number of points: if the score is high enough, we're sure that this is spam, if not, we can let the message through. To install SpamAssassin, just use # yum -t install spamassassin Edit the bayes_path /var/amavis/.spamassassin/bayes auto_whitelist_path /var/amavis/.spamassassin/auto-whitelist lock_method flock trusted_networks 1.2.3.4 internal_networks 1.2.3.4 The last 2 lines are only necessary if your server is using NAT to hide being a firewall and has a local LAN address: you need to tell SpamAssassin about it or it might consider as trusted emails coming from the outside. Change the Now we need to make some changes to ensure that what we do as # spamassassin --lint -D # cp -ir /root/.spamassassin /var/amavis # cd /root/.spamassassin/ # rm -f user_prefs # ln -s /var/amavis/.spamassassin/user_prefs user_prefs # chown -R amavis.amavis /var/amavis Now, make sure SpamAssassin will run when we boot: # chkconfig --levels 235 spamassassin on # service spamassassin start Initialise the Bayesian database: # sa-learn --sync Test our config by running: # amavisd debug-sa If what you did above was done properly, you should see debug: using "/var/amavis/.spamassassin/user_prefs" for user prefs file in the middle of all those spewed by Amavisd-New (scroll back or use Shift+PageUp keys). Testing antispamJust send an email with the following in the body: This is a standard fake spam signature used to test antispam software. You should get the email with the Baysian filteringSpamassassin includes a powerful statistical analysis that can help toward refining the score given to emails passing through it. The only drawback with baysian analysis is that it needs a set of good (ham) and bad (spam) emails large enough to be accurate, and you need to sort these emails and manually train spamassassin. To avoid any aggravation, I created a simple MissedSpam folder in one of the IMAP mail accounts that I use. I then simply have to move any spam that made its way to an inbox into that folder. To train spamassassin as to what is spam and what is ham, make sure you have enough segregated emails (between 150-3000) in each mailbox being trained then issue the following: # sa-learn --spam --sync /mail/postmaster/.MissedSpam/cur/ That would train spamassassin to recognise spam better. # sa-learn --ham --sync /mail/emily/cur/ # sa-learn --ham --sync /mail/john/cur/ ... Make sure that the database ownership has not been reclaimed by # chown amavis.amavis -R /var/amavis If you do this regularly the amount of spam that managed to get through should reduce. Resources< AmavisdNew | EmailServer | SpamAssassinImproved > Comments |