Guide updated on 29th of February 2016

Configure spamassassin


Spamassassin is the antispam system we 'll use

Enable Spamassassin

systemctl enable spamassassin.service

Edit /etc/default/spamassassin to change the options :

OPTIONS="--create-prefs --max-children 5 --helper-home-dir -u vpopmail -v -x -i -m 5 -c -H -s mail --virtual-config-dir=/home/vpopmail/.spamassassin"

IP::Country::Fast perl installation

Install perl package (deb)

dpkg -i /downloads/deb-packages/libip-country-perl_2.28-1_all.deb

Take the latest version of IP database from http://mailfud.org/ip-country-fast/

cd /usr/share/perl5/IP/Country/Fast
mv cc.gif cc.gif.old
mv ip.gif ip.gif.old
wget http://mailfud.org/ip-country-fast/cc.gif
wget http://mailfud.org/ip-country-fast/ip.gif
cd /downloads/

Configure pyzor

Add the Pyzor servers by running the following command.

pyzor --homedir /etc/spamassassin discover
chmod 666 /etc/spamassassin/servers

OPTIONAL : If you want to report spam with the Vipul's Razor spam-reporting system

razor-admin -d -home=/etc/razor -create
razor-admin -d -home=/etc/razor -register

Load additionnal plugins

Uncomment this in /etc/spamassassin/init.pre (line 22)

loadplugin Mail::SpamAssassin::Plugin::RelayCountry

Uncomment this in /etc/spamassassin/v310.pre (line 24)

loadplugin Mail::SpamAssassin::Plugin::DCC

Uncomment this in /etc/spamassassin/v320.pre (line 53)

loadplugin Mail::SpamAssassin::Plugin::Rule2XSBody

Enable additionnal features

Edit /etc/spamassassin/local.cf to change the following options :

Uncomment following lines

required_score 5.0
use_bayes 1
bayes_auto_learn 1

Add following lines

score BAYES_99 5.300

add_header all Relay-Country _RELAYCOUNTRY_
skip_rbl_checks 1

use_pyzor 1
pyzor_options --homedir /etc/spamassassin/

use_razor2 1
razor_config /etc/razor/razor-agent.conf

OPTIONAL : If you want to change mail classification based on relaying countries, add following lines in /etc/spamassassin/local.cf

header RELAYCOUNTRY_BAD X-Relay-Countries =~ /CN/
describe RELAYCOUNTRY_BAD Relayed through China at some point
score RELAYCOUNTRY_BAD 3.0

header RELAYCOUNTRY_GOOD X-Relay-Countries =~ /^(BE|FR)/
describe RELAYCOUNTRY_GOOD Relayed through Belgium or France
score RELAYCOUNTRY_GOOD -0.2

Create a compiled version of some ruleset

sa-compile

Test configuration and start the service

/usr/bin/spamassassin -D --lint

systemctl start spamassassin

OPTIONAL : If you want qmail-smtpd to reject messages where the domain portion of the envelope sender is not a valid domain (feature non-related to spamassassin but added by patch qmail-1.03-mfcheck.3.patch.)

echo 1 > /var/qmail/control/mfcheck

Configure courier


Users comments