SPAMASSASSIN
The installation of SpamAssassin should be performed as per SpamAssassin documentation.
This guide is available for information purposes, though the information contained in this guide has been rendered obsolete.
We strongly recommend that you read through the Amavisd-New Guide and implement SpamAssassin as part of that solution.
----
The daemon spamd should be running, and a good practice would be to verify that it is running as part of the Postfix start script. Once SpamAssassin is installed and running, you will need to perform the following:
#!/bin/sh
# spamfilter.sh
INSPECT_DIR=/var/spam
SENDMAIL=/usr/sbin/sendmail
SPAMASSASSIN=/usr/bin/spamc
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
trap "rm -f in.$$; rm -f out.$$" 0 1 2 3 15
cat | $SPAMASSASSIN -f > out.$$ #|| # { echo Message content rejected; exit $EX_UNAVAILABLE; }
$SENDMAIL "$@" < out.$$
exit $?NOTE: On our servers, prior to migrating to the Amavisd-New solution, we used to use another re-injection listener, and a perl script to send the output of the spamfilter script back into the correct queue. This is due to the multiple steps of filtration that are used on our servers, and the problem created when messages are fed back into a the wrong queue (creating a mail loop). Please see this perl script for how to do this. If you are using an AntiVirus softwre package with Postfix, it is almost a certainty that you will have to use this perl script and modified spamfilter script.
NOTE: Make sure you start up SpamAssassin spamd properly. On our servers we use the following parameters for spamd when started in rc scripts:
-d Runs the program in daemon mode -r /var/run/spamd.pid Sets the pid file -a Use auto-whitelists -u spam Run as user spamfilter -x Disable user config files (since we run global) -H /var/spam Specify home directory Upon installing SpamAssassin, you will also have a file named local.cf placed in /etc/mail/spamassassin (or elsewhere depening on your installation). This file will contain additional details about how you want your system to run. Please see the SpamAssassin Conf documentation for more information about the local.cf file and other configurations. We strongly recomend that you enable auto-whitelist and bayes. Installing Razor2 would also be very beneficial.