User Tools

Site Tools



Spamassassin is a anti-spam software that can be integrated into major mail servers like Postfix. Spamassassin uses various methods for detecting if a mail is spam or not. Each mail gets a spam rating. If a predefined threshold is exceeded than Spamassassin marks the mail as spam.

Depening on the configuration the mail header and/or mail subject contian spam markers.

Popular mail clients and server side mail filters like procmail use those markers to put those mails into separate spam folders or delete them.


The following article describes a minimal spamassassin installation on Debian Linux, where spamassassin is integrated into an existing Postfix installation.

apt-get --no-install-recommends install spamassassin spamc

The list of spamassassin's dependencies is long. And it is even longer if you install the recommended packages on top of the required ones. The –no-install-recommends switch prevents this.

Running spamassassin under its own user account

On Debian Spamassassin runs as root by default. Postfix will not cooperate in that case, so we will run spamassassin under a new user called spamd instead.

groupadd spamd
useradd -g spamd -s /sbin/nologin -d /var/lib/spamassassin spamd
mkdir /var/log/spamd /var/run/spamd
chown spamd:spamd /var/lib/spamassassin /var/log/spamd /var/run/spamd

This is what you do in detail:

  1. Create a new group called spamd
  2. Create a new user spamd
  3. Make the user spamd a member of the group spamd
  4. Create the directories neccessary for Spamassassins runtime data


Make the following settings in /etc/default/spamassassin:

OPTIONS="--create-prefs --max-children 5 --username spamd --helper-home-dir ${SAHOME} -s /var/log/spamd/spamd.log"

For System-V init based systems (below Debian Jessie) also set:


Uncomment the following line in /etc/mail/spamassassin/

rewrite_header Subject *****SPAM*****

Changes in /etc/postfix/

smtp         inet  n     -       -       -       -       smtpd       -o content_filter=spamassassin
spamassassin unix  -     n       n       -       -       pipe        user=spamd argv=/usr/bin/spamc -f -e    /usr/sbin/sendmail -oi -f ${sender} ${recipient}

For systemd based systems (Debian Jessie and later) enable the spamassassin service:

systemctl enable spamassassin.service

Starting the new installation

Below Debian Jessie:

/etc/init.d/postfix restart
/etc/init.d/spamassassin start

Debian Jessie and later:

service postfix restart
service spamassassin start


spamassassin.txt · Last modified: 2015/12/13 10:50 by sebastian