Configuring Spamassassin + Postfix

I’ll give an example of installing and configuring Spamassassin to filter spam.

In Ubuntu Server, I switched to the root user and installed Spamassassin:

sudo su
apt-get install spamassassin spamc

During installation, the user “debian-spamd” was automatically created.

In the file /etc/default/spamassassin, specify:

ENABLED=0
#OPTIONS="--create-prefs --max-children 5 --helper-home-dir"
OPTIONS="--create-prefs --max-children 5 --helper-home-dir --username debian-spamd -s /var/log/spamd.log"
CRON=1

In the file /etc/spamassassin/local.cf, specify:

rewrite_header Subject *****SPAM*****
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_pyzor 0

In the file /etc/postfix/master.cf we find the line:

smtp      inet  n       -       y       -       -       smtpd

And under it, add a line through the space:

-o content_filter=spamassassin

And also add at the end of the file (before the last two lines and add spaces):

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

Check the configuration of Postfix and restart it to apply the changes:

postfix check
systemctl status postfix.service
systemctl restart postfix.service

We activate spamassassin autostart when the operating system starts and start it:

systemctl status spamassassin.service
systemctl is-enabled spamassassin.service
systemctl enable spamassassin.service
systemctl restart spamassassin.service

See also my articles:
Installing and Configuring Postfix
How to configure SPF records
How to remove an IP address from email blacklists

Leave a comment

Leave a Reply