This article is outdated and may not work correctly for current operating systems or software.
Spamassassin is a free and open-source mail filter written in Perl that is used to identify spam using a wide range of heuristic tests on mail headers and body text. It will save your mailbox from much unwanted spam emails.
Before installing Spamassassin, you need to install and configure a mail transfer agent such as Postfix on your virtual private server. The following instructions are for using Spamassassin with Postfix.
Verify the server's outbound port status.
Install Spamassassin.
apt-get install spamassassin spamc
Add a Spamassassin user.
adduser spamd --disabled-login
Edit the configuration settings at /etc/default/spamassassin
.
ENABLED=0
OPTIONS="--create-prefs --max-children 5 --username spamd --helper-home-dir /home/spamd/ -s /home/spamd/spamd.log"
CRON=1
Now we will edit /etc/spamassassin/local.cf
to set up some anti-spam rules.
rewrite_header Subject ***** SPAM _SCORE_ *****
report_safe 0
required_score 5.0
use_bayes 1
use_bayes_rules 1
bayes_auto_learn 1
skip_rbl_checks 0
use_razor2 0
use_dcc 0
use_pyzor 0
Edit /etc/postfix/master.cf
and add a content filter to your SMTP server.
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 the changes to take effect, restart Postfix.
systemctl restart postfix.service
systemctl enable spamassassin.service
systemctl start spamassassin.service