Install Spamassassin on Ubuntu 12.04

From vpsget wiki
Revision as of 17:27, 1 September 2016 by Ndi (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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:

ENABLED=1
SPAMD_HOME="/home/spamd/"
OPTIONS="--create-prefs --max-children 5 --username spamd --helper-home-dir ${SPAMD_HOME} -s ${SPAMD_HOME}spamd.log"
PIDFILE="${SPAMD_HOME}spamd.pid"
CRON=1

Open the file /etc/spamassassin/local.cf:

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/master.cf:

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

Test:

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 myserver.com
X-Spam-Level: 
X-Spam-Status: No, score=0.3 required=5.0 etc. etc.

Source: http://www.geoffstratton.com/2013/06/mail-server-spamassassin/

Example spamassasing config: Config usually located : /etc/mail/spamassassin/local.cf

# These values can be overridden by editing ~/.spamassassin/user_prefs.cf 
# (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 domain1.com:
whitelist_from  *@domain1.com
# whitelist everyone at domain2.com:   
whitelist_from  *@domain2.com    
trusted_networks 11.11.250.60 
header ALLOWN4H Received=~ /\[11.11.250.60\]/
score ALLOWN4H  -9
describe ALLOWN4H Allows relays from 11.11.250.60 
whitelist_from  *@webhostingtalk.com
whitelist_from  *@www.webhostingtalk.com
#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