SpamAssassin Configuration in Debian        

What is SpamAssassin?

SpamAssassin is a mail filter to identify spam. It is an intelligent email filter which uses a diverse range of tests to identify unsolicited bulk email, more commonly known as Spam. These tests are applied to email headers and content to classify email using advanced statistical methods. In addition, SpamAssassin has a modular architecture that allows other technologies to be quickly wielded against spam and is designed for easy integration into virtually any email system.


  • Wide-spectrum: SpamAssassin uses a wide variety of local and network tests to identify spam signatures. This makes it harder for spammers to identify one aspect which they can craft their messages to work around.
  • Free software: it is distributed under the same terms and conditions as other popular open-source software packages such as the Apache web server.
  • Easy to extend: Anti-spam tests and configuration are stored in plain text, making it easy to configure and add new rules.
  • Flexible: SpamAssassin encapsulates its logic in a well-designed, abstract API so it can be integrated anywhere in the email stream. The Mail::SpamAssassin classes can be used on a wide variety of email systems including procmail, sendmail, Postfix, qmail, and many others.
  • Easy Configuration: SpamAssassin requires very little configuration; you do not need to continually update it with details of your mail accounts, mailing list memberships, etc. Once classified, site and user-specific policies can then be applied against spam. Policies can be applied on both mail servers and later using the user's own mail user-agent application.

 Install Debian's spamassassin package :

# apt-get install spamassassin

Debian's spamassassin package is clever enough to install all the required dependencies and includes the spamd binaries (see bellow).

Edit /etc/default/spamassassin and change the value of ENABLED

variable from 0 to 1 in order to allow spamd to start.

Start spamassassin daemon :

# /etc/init.d/spamassassin start

The above command will actually start spamd, a daemonized version of  SpamAssassin, which is much quicker than the official Perl version as it actually loads all SpamAssassin rules once at startup and there is no further need to read and load again all the rules every time spamc (see bellow) pipe a message to spamd.

Spamassassin is installed. Let's make some tweaks. First, we're going to add a user/group called "spamd" under which Spamassassin will be run

groupadd spamd

useradd -g spamd -s /bin/false -m -d /home/spamassassin spamd

Next, we set the spam threshold value and rewrite subject variable

vi /etc/mail/spamassassin/

Replace the contents of the file with the following config settings:

rewrite_subject 1
required_hits 5

Save and exit from the file.

And now, let's put a Spamassassin startup script in place...

cp /downloads/spam/debian_spamd /etc/init.d/spamd

mkdir /var/run/spamd

chown -R spamd:spamd /var/run/spamd

The init script contains a variable specifying the location of spamd. Let's make sure it's correct. First, find out where spamd resides

whereis spamd

You should get an answer like /usr/local/bin/spamd or /usr/bin/spamd or something like that. Make a note of where spamd is located.

Now, open the /etc/init/dspamd init script for editing

vi /etc/init.d/spamd

Make sure that the following variable reflect the correct location of spamd:


And now let's crank up Spamassassin

/etc/init.d/spamd stop

/etc/init.d/spamd start

If spamd has started successfully, a "ps -aux | grep spam " command should reveal it...

spamd 283 0.0 2.1 21152 19328 ? S 04:33 0:01 /usr/local/bin/spamd -x -u spamd -H /home/spamd -d --pidfile=/var/run/spamd/
spamd 339 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child
spamd 340 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child
spamd 341 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child
spamd 342 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child
spamd 343 0.0 2.1 21152 19328 ? S 04:33 0:00 spamd child

Once you have spamassin successfully operating, let's configure the server so that spamd will start up on boot. We'll do this just like we did with clamd

update-rc.d spamd start 75 2 3 4 5 .

The above command should create the needed init symlinks for the 2, 3, 4 and 5 runlevels.