Referencing my previous
article about the mali server configuration, I'm continuing with spam and antivirus scanners setup. On my Debian box i'm installing the following:
BASH:
user@host~$ apt-get install spamassassin
With this groups spamd and clamav are automatically created. Before you start, keep in mind - if something goes wrong, allways check the /var/log/mail.* files.
Embedding Spamassassing into the Postfix is quite easy. First lets setup Spamassassinn, for this edit (or create) /etc/spamassassin/local.cf:
BASH:
rewrite_header Subject *****SPAM*****
report_safe 1
required_score 2.5
use_bayes 1
use_bayes_rules 1
bayes_auto_learn 1
bayes_ignore_header X-Bogosity
bayes_ignore_header X-Spam-Flag
bayes_ignore_header X-Spam-Status
Note, rewritten subject could include the determined score (for example like *****SPAM _SCORE_*****), but for this one needs to set report_safe to 0 (which means, the message itself will be changed)
On Debian I had to edit the /etc/default/spamassassin:
BASH:
ENABLED=1
OPTIONS="--create-prefs --max-children 5 --helper-home-dir --virtual-config-dir=/srv/mail/spamassassin -x -u spamd"
PIDFILE="/var/run/spamd.pid"
After all this spamassassin can be restarted:
BASH:
user@host~$ /etc/init.d/spamassassing restart
Now we must learn the Postfix to use that spam filter service. For this edit /etc/postfix/master.cf, create or edit the parts:
BASH:
smtp inet n - 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}
This will make Postfix to deliver each mail piping it to the Spamassassin. Just reload the Postfix configs to make it work.
That's it, enjoy.
Userfull links:
http://www.debuntu.org/postfix-and-pamassassin-how-to-filter-spam
http://wiki.linuxquestions.org/wiki/Postfix_with_clamav-milter