User:Paul/sandbox/Install SpamAssassin

WARNING: This article is in a user sandbox, indicating it is a rough draft, and as such, is likely incomplete, contains buggy and insecure configurations, and is subject to substantial and frequent changes.

Most of the commands in this article require  privileges:

username@servername:~$ sudo /bin/bash

Install and configure SpamAssassin
Install the base set of packages:

root@servername:~# aptitude install spamass-milter pyzor razor libmail-dkim-perl

The SpamAssassin milter will require the  user, which needs to be created:

root@servername:~# adduser --shell /bin/false --home /var/lib/spamassassin --disabled-password --disabled-login --gecos "" spamd root@servername:~# usermod -a -G spamd spamass-milter root@servername:~# mv /etc/default/spamassassin /etc/default/original.spamassassin root@servername:~# nano /etc/default/spamassassin

Paste into the new file: SAHOME="/var/lib/spamassassin" SAGLOBALCFGPATH="/etc/spamassassin" ENABLED=1 OPTIONS="--max-children 5 --helper-home-dir ${SAHOME} -u spamd -g spamd --siteconfigpath ${SAGLOBALCFGPATH} --socketpath=/var/spool/postfix/spamassassin/spamd.sock --socketowner=spamd --socketgroup=spamd --socketmode=0660" PIDFILE="/var/run/spamd.pid" CRON=1 Configure to interface with Postfix through unix domain sockets:
 * 1) Change to one to enable spamd
 * 1) Options
 * 2) See man spamd for possible options. The -d option is automatically added.
 * 1) Pid file
 * 2) Where should spamd write its PID to file? If you use the -u or
 * 3) --username option above, this needs to be writable by that user.
 * 4) Otherwise, the init script will not be able to shut spamd down.
 * 1) Cronjob
 * 2) Set to anything but 0 to enable the cron job to automatically update
 * 3) spamassassin's rules on a nightly basis

root@servername:~# mkdir /var/spool/postfix/spamassassin root@servername:~# chown spamd:root /var/spool/postfix/spamassassin/ root@servername:~# nano /etc/default/spamass-milter

Comment out the default  and paste in:

OPTIONS="-u spamass-milter -i 127.0.0.1 -m -I -- --socket=/var/spool/postfix/spamassassin/spamd.sock"

root@servername:~# nano /etc/spamassassin/local.cf

Add: razor_config /var/lib/spamassassin/.razor/razor-agent.conf pyzor_options --homedir /var/lib/spamassassin/.pyzor
 * 1) Set Pyzor & Razor config file paths

root@servername:~# mkdir /var/lib/spamassassin/{.razor,.pyzor,.spamassassin} root@servername:~# pyzor --homedir /var/lib/spamassassin/.pyzor discover root@servername:~# razor-admin -home=/var/lib/spamassassin/.razor -register root@servername:~# razor-admin -home=/var/lib/spamassassin/.razor -create root@servername:~# razor-admin -home=/var/lib/spamassassin/.razor -discover root@servername:~# chown spamd:spamd -R /var/lib/spamassassin/ root@servername:~# nano /var/lib/spamassassin/.razor/razor-agent.conf

Add: razorhome = /var/lib/spamassassin/.razor

root@servername:~# service spamassassin restart && service spamass-milter restart root@servername:~# spamassassin --lint root@servername:~# sa-update

Next step
Configure Dovecot