CSUF LogoCSUF Site Navigation

F14 E-Mail & Spam Spam Filtering with SpamAssassin

Department of Electrical and Computer Engineering
Associate Professor Gregory R. Kriehn
F14 Spam Filtering with SpamAssassin

SpamAssassin is a statistical Bayesian anti-spam filter, initially based on the work of Paul Graham and his technical paper "A Plan for Spam". It is currently my preferred anti-spam filter due to its simplicity.

At this point, I assume that if you are reading this that you already have your e-mail properly setup. If not, I strongly suggest reading the sendmail and fetchmail pages. As a review, I have chosen to setup my e-mail by using fetchmail to poll the University's mail server once a minute, where it is then forwarded via formail one e-mail at a time through procmail, which launches python to run spamassassin and classify the e-mail. fetchmail was discussed in detail in the fetchmail page (and to a lesser degree, formail and procmail as well), so spamassassin will be primarily discussed here, although we will have to do some further editing to the ~/.procmailrc file.

Install SpamAssassin

The first step in the installation process is to install the spamassassin package with yum:
~> sudo yum install spamassassin
Enable the service on the appropriate run levels:
~> sudo chkconfig --level 345 spamassassin on
Re-start the daemon:
~> sudo service spamassassin restart
Stopping spamd:                                            [  OK  ]
Starting spamd:                                            [  OK  ]

Setup Procmail

Next edit the ~/.procmailrc file and add the following lines before the # Put everything else in the INBOX line:
# SpamAssassin sample procmailrc
# Pipe the mail through spamassassin (replace 'spamassassin' with 'spamc'
# if you use the spamc/spamd combination)
# The condition line ensures that only messages smaller than 250 kB
# (250 * 1024 = 256000 bytes) are processed by SpamAssassin. Most spam
# isn't bigger than a few k and working with big messages can bring
# SpamAssassin to its knees.
# The lock file ensures that only 1 spamassassin invocation happens
# at 1 time, to keep the load down.
* < 256000
| /usr/bin/spamc -f

# Put everything else in the INBOX
Save and exit.

Integrate SpamAssassin into Evolution

To automatically move spam into your Junk filter in Evolution, click on Edit -> Preferences -> Mail Preferences -> Junk.  Click on the Add button to add two custom headers:
Header Name: X-spam-level
Header Value Contains: *****
Header Name: X-spam-status
Header Value Contains: Yes
Make sure the custom headers for junk box is clicked, and Evolution should now move your e-mail around to the appropriate location based upon SpamAssassin's classification.

No more presidents of Zimbabwe offering $10,000,000.00 if you provide them with your bank account information. No more male augmentation pills, rol3x watch3z, and all that other junk overwhelming your Inbox. Life is good.