Install Spamassassin on Ubuntu 12.04

From vpsget wiki
Jump to: navigation, search

Install spamassassin:

apt-get install spamassassin spamc
adduser spamd --disabled-login

Open the file /etc/default/spamassassin and add/edit the following lines:

OPTIONS="--create-prefs --max-children 5 --username spamd --helper-home-dir ${SPAMD_HOME} -s ${SPAMD_HOME}spamd.log"

Open the file /etc/spamassassin/

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 the file /etc/postfix/

smtp      inet  n       -       -       -       -       smtpd
       -o content_filter=spamassassin

Add to the end of the same file:

spamassassin unix -     n       n       -       -       pipe
       user=spamd argv=/usr/bin/spamc -f -e  
       /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Restart services:

service spamassassin start
service postfix restart


Send a test email from gmail or other provider to your server and see the headers. If all works good, headers should contain the following:

X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
X-Spam-Status: No, score=0.3 required=5.0 etc. etc.


Example spamassasing config: Config usually located : /etc/mail/spamassassin/

# These values can be overridden by editing ~/.spamassassin/ 
# (see spamassassin(1) for details)
# These should be safe assumptions and allow for simple visual sifting
# without risking lost emails.
required_hits 5.0
report_safe 0
required_score 5
rewrite_header Subject [SPAM]
# whitelist everyone at
whitelist_from  *
# whitelist everyone at   
whitelist_from  *    
header ALLOWN4H Received=~ /\[\]/
score ALLOWN4H  -9
describe ALLOWN4H Allows relays from 
whitelist_from  *
whitelist_from  *
#useBayes 1
#auto_learn 0
#auto_learn 1
use_bayes 1
bayes_auto_learn 1
bayes_auto_learn_threshold_nonspam -0.001
bayes_auto_learn_threshold_spam 10.0
#bayes_path /var/spamassassin/bayes/
#bayes_file_mode     077