SpamAssassin on Debian Linux in less than a minute
There are various ways of using Spamassassin (SA) to filter and tag emails. A basic and generic one is shown here, this will
- determine the likelyhood of an email being spam using SA and
- deliver emails into different user mail folders based on the SA spam score.
- No risk: No email or sender will be blocked, rejected or deleted.
While this approach is independent of the mail tranport agent (MTA) used (e.g. Postfix , Exim , etc.), is uses procmail to deliver emails into different folders using Maildir-style user mailboxes (rather than mbox).
Preparation
- Get spamassassin via aptitude
- Optional: Install the tools suggested by the spamassassin package:
razor ,
dcc -client and
pyzor that access spam databases on
the internet to help calculating the spam score of an email.
Installation
In user's home directory
mkdir .spamassassin
- Create a file .procmailrc in the user's home directory
MAILDIR=$HOME/Maildir DEFAULT=$HOME/Maildir/new LOGFILE=$HOME/Maildir/proc.log # check mail smaller than 250KB with spamassassin :0fw * < 256000 | /usr/bin/spamassassin # Catch SPAM and deliver suspected spam to Spam folder, # while moving emails with scores above six to Spam/Plus :0: * ^X-Spam-Level: \*\*\*\*\*\* $HOME/Maildir/.Spam.Plus/cur :0: * ^X-Spam-Flag: YES $HOME/Maildir/.Spam/cur
Test
Send yourself some test mails. You should see tags added by SpamAssassin in the mails header, e.g
X-Spam-Level: ****** X-Spam-Flag: YES X-Spam-Status: ....(some text)...
and procmail should have delivered emails depending on their spam score to either your Inbox, your Spam or your Spam/Plus folder.
Conclusion
With a few simple steps you now have a spam filter on your machine that reduces the amount you spam in your inbox daramtically. You may occasionally want to check the Spam folder so that you do not miss any emails that have been regarded as spam by mistake (aka False Positives, FP). What gets delivered into the Spam/Plus folder should most certianly be spam which you will not want to look at.
Read on if you want to know more about SpamAssassin's features.