SpamAssassin is an Open Source anti-spam platform that attempts to filter spam by examining incoming emails in the CentOS Web Panel integrated with the Postfix Mail Server.
Although the SpamAssassin service is running we cannot see Spam filtering is working. Therefore this tutorial will walk you through how to configure SpamAssain on CentOS Web Panel.
There are Three configuration files that need to be edited in the SpamAssassin and Postfix Mail Server. Two configuration files in SpamAssain and one with the Postfix Mail Server.
Now Let’s see how we can configure these configuration files.
CONFIGURE SPAMASSASSIN
1st open /etc/mail/spamassassin/local.cf running the command below.
vim /etc/mail/spamassassin/local.cf
Then edit the configuration file with the settings below.
Here is the explanation of each setting of the above configuration. You can configure the level accordingly.
Required_hits: This determines the filter balance; the lower the score the more aggressive the filter. A setting of 5.0 is generally effective for a small organisation or a single user. Adjust the strictness score to your organization’s needs – a large medical organisation might want to let email items through that are trying to sell pharmaceuticals, so we might increase the level to a more modest 8.0.
Report_safe: This line determines whether to delete the item or to move the item to the inbox whilst appending a spam notice to the subject line. The levels for this line are set to either a 1 or 0. A score of 1 will delete the spam item, whereas a score of 0 will send the item to the inbox and rewrite the subject line. For this guide we shall use 0 as the score.
Required_score: This line sets the spam score for all email alllowed through to your domain, with levels of certainty set from 0 to 5. Zero would be classified as a legitimate email item, whereas 5 would be an definite ‘SPAM’ item. If we set the score to 3 we would catch a lot of unsolicited emails but quite a few false positives would still get through. For our example email server we will use the score of 5, but you can of course set this value according to your preference.
Rewrite_header: This line does exactly what it implies, that is, any message caught as ‘SPAM’ will have the subject line rewritten to include this header. For this guide we will use the default subject header of [***SPAM***].
2nd configuration file that we need to edit is /etc/sysconfig/spamassassin file. Edit/add the file with below config and save it.
CONFIGURE POSTFIX
The 3rd configuration file is with Postfix. Open the file
/etc/postfix/master.cf and edit/add the config below then save it.
You have configured three required files and now restart SpamAssasin Anti-Spam service and Postfix Mail Server service using the commands below.
systemctl restart spamassassin.service
systemctl restart postfix.service
TEST SPAM FILTERING
Login to your Gmail account. Compose an email with the subject line below and send it to an email address in the newly-configured mail server. More about The GTUBE.
Also to make sure that the legitimate emails are working properly send another proper email with a good subject line. You will see those emails will be arrived to Inbox as usual.
That’s it.
Although the SpamAssassin service is running we cannot see Spam filtering is working. Therefore this tutorial will walk you through how to configure SpamAssain on CentOS Web Panel.
There are Three configuration files that need to be edited in the SpamAssassin and Postfix Mail Server. Two configuration files in SpamAssain and one with the Postfix Mail Server.
Now Let’s see how we can configure these configuration files.
CONFIGURE SPAMASSASSIN
1st open /etc/mail/spamassassin/local.cf running the command below.
vim /etc/mail/spamassassin/local.cf
Then edit the configuration file with the settings below.
Code:
required_hits 5 report_safe 0 required_score 5 rewrite_header Subject [***SPAM***]
Here is the explanation of each setting of the above configuration. You can configure the level accordingly.
Required_hits: This determines the filter balance; the lower the score the more aggressive the filter. A setting of 5.0 is generally effective for a small organisation or a single user. Adjust the strictness score to your organization’s needs – a large medical organisation might want to let email items through that are trying to sell pharmaceuticals, so we might increase the level to a more modest 8.0.
Report_safe: This line determines whether to delete the item or to move the item to the inbox whilst appending a spam notice to the subject line. The levels for this line are set to either a 1 or 0. A score of 1 will delete the spam item, whereas a score of 0 will send the item to the inbox and rewrite the subject line. For this guide we shall use 0 as the score.
Required_score: This line sets the spam score for all email alllowed through to your domain, with levels of certainty set from 0 to 5. Zero would be classified as a legitimate email item, whereas 5 would be an definite ‘SPAM’ item. If we set the score to 3 we would catch a lot of unsolicited emails but quite a few false positives would still get through. For our example email server we will use the score of 5, but you can of course set this value according to your preference.
Rewrite_header: This line does exactly what it implies, that is, any message caught as ‘SPAM’ will have the subject line rewritten to include this header. For this guide we will use the default subject header of [***SPAM***].
2nd configuration file that we need to edit is /etc/sysconfig/spamassassin file. Edit/add the file with below config and save it.
Code:
SAHOME="/var/lib/spamassassin/" SPAMDOPTIONS="-d -c -m5 -H --username nobody -s ${SAHOME}spamd.log"
CONFIGURE POSTFIX
The 3rd configuration file is with Postfix. Open the file
/etc/postfix/master.cf and edit/add the config below then save it.
Code:
smtp inet n - n - - smtpd -o content_filter=smtp-amavis:127.0.0.1:10024 -o receive_override_options=no_address_mappings -o content_filter=spamassassin spamassassin unix - n n - - pipe user=nobody argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
You have configured three required files and now restart SpamAssasin Anti-Spam service and Postfix Mail Server service using the commands below.
systemctl restart spamassassin.service
systemctl restart postfix.service
TEST SPAM FILTERING
Login to your Gmail account. Compose an email with the subject line below and send it to an email address in the newly-configured mail server. More about The GTUBE.
Code:
[B]XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X[/B]
Also to make sure that the legitimate emails are working properly send another proper email with a good subject line. You will see those emails will be arrived to Inbox as usual.
That’s it.