Apache SpamAssassin is a computer program used to filter email spam. It uses a variety of spam detection techniques including DNS and fuzzy checksum techniques, Bayesian filtering, external programs, blacklists, and online databases. It is released under the Apache License 2.0 and has been part of the Apache Foundation since 2004. This program is required for any, even the simplest server, which has mail. The guide is geared towards servers that run Ubuntu. You should also make sure that the 25th port of Smtp is open.
SpamAssasin installation process
In order to install this program, we recommend the following command:
apt-get install spamassassin spamc -y
The next step is to install the user and disable the login.
adduser spamassasin --disabled-login
Configuring SpamAssasin
Assign spamassassin to the SpamAssassin user account. This is followed by editing the settings
nano /etc/default/spamassassin
It is necessary to find in this directory ENABLED = 1 Uncomment it by removing the # and changing the value from 1 to 0.
ENABLED=0
Then you need to find the line OPTIONS = “- create-prefs –max-children 5 –helper-home-dir” and make changes. They must include a spamassassin account
OPTIONS="--create-prefs --max-children 5 --username spamassassin --helper-home-dir /home/spamassassin/ -s /home/spamassassin/spamassassin.log"
Then you need to find the line CRON = 0 and make the same changes as before to get CRON = 1. Then save the file. Back up your local SpamAssassin configuration file.
mv /etc/spamassassin/local.cf /etc/spamassassin/local.cf.bk
Then you need to create a new local SpamAssassin configuration file.
nano /etc/spamassassin/local.cf
Paste the information below into the file.
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
ifplugin Mail::SpamAssassin::Plugin::Shortcircuit
endif
The next step is to save the change file and then you can close it.
Setting up your Postfix
First of all, to start configuring, you need to edit the Postfix configuration file
nano /etc/postfix/master.cf
Next, you need to find the following records, which are presented below:
smtp inet n - y - - smtpd
#smtp inet n - y - 1 postscreen
#smtpd pass - - y - - smtpd
#dnsblog unix - - y - 0 dnsblog
#tlsproxy unix - - y - 0 tlsproxy
submission inet n - y - - smtpd
Under smtp configuration add SpamAssassin content filter
smtp inet n - y - - smtpd
-o content_filter=spamassassin
spamassassin unix - n n - - pipe
user=spamassassin argv=/usr/bin/spamc -f -e
/usr/sbin/sendmail -oi -f ${sender} ${recipient}
Next, you should save this file and you can then close it. This is followed by restarting your Postfix and enabling spamassassin to run on your server.
systemctl restart postfix.service
systemctl enable spamassassin.service
systemctl start spamassassin.service
Leave A Comment?