Home > Linux Administration > SpamAssassin on Debian

SpamAssassin on Debian

October 21st, 2008

Prerequisites

A current Debian system with an MTA installed and working. This guide is specific to Exim4 although many of the steps would apply to other MTA’s as well. Also, the guide assumes you store your mail in Maildir format. If you store your mail in single files (mbox), you will have to adjust some of the commands below.

Install Packages

Use aptitude or apt-get to install the packages ’spamassassin’ and ’sa-exim.’

Configuration

Create a file called .forward in your home directory with the following content. If needed, update the save command to point to the location of your junk/spam directory.

# Exim filter
if $h_X-Spam-Status: CONTAINS "Yes"
or
$h_X-Spam-Flag: CONTAINS "Yes"
then
save $home/Maildir/.Junk/
finish
endif

Edit /etc/exim4/sa-exim.conf and comment out the second SAEximRunCond attribute like so:

# Remove or comment out the following line to enable sa-exim
#SAEximRunCond: 0

Edit /etc/default/spamassassin and change the ENABLED flag to 1.

Finally, start spamassassin and configure it to start at boot if needed:

# /etc/init.d/spamassassin start
# update-rc.d spamassassin defaults

 

Optimization and Maintenence

Take a look at the log file /var/log/exim4/mainlog. You should see SpamAssassin doing its thing for any new emails coming in. You will see what spam ranking it assigns to the message and what its fate is (allowed, allowed but flagged, or permanently rejected).

A good way to increase the accuracy of SpamAssasin is to teach it. First, organize your spam and non-spam (which we will call “ham”) into separate folders. Try to make sure you don’t miscategorize any. For this to work well, you will need over a hundred of each type of email–the more the better. Then, run the ’sa-learn’ command on the folders. For example, assuming your ham is in your inbox and your spam is in a folder called Junk:

$ sa-learn --ham --showdots /home/username/Maildir/cur/*
$ sa-learn --spam --showdots /home/username/Maildir/.Junk/cur/*

Linux Administration , , , ,

  1. No comments yet.
  1. No trackbacks yet.