How To: Configure SpamAssassin on CWP Pro

How To's + Postfix + SpamAssassin taylor todayDecember 7, 2021 404

share close

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.

Configure SpamAssassin

Firstly, open /etc/mail/spamassassin/local.cf

Then edit the file using your favorite file editor as follows:

required_hits 5
report_safe 0
required_score 5
rewrite_header Subject [!! SPAM !!]

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 SpamAssassin Config Change

Next, edit /etc/sysconfig/spamassassin and add the following:

SPAMDOPTIONS="-d -c -m5 -H --username nobody -s ${SAHOME}spamd.log"

Configure Postfix

Next open /etc/postfix/master.cf with your favorite file editor and edit the following:

smtp      inet  n       -       n       -       -       smtpd
  -o content_filter=smtp-amavis:
  -o receive_override_options=no_address_mappings
  -o content_filter=spamassassin

Then, add the following at the end of the document above Dovecot LDA:

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


Now that all files are modified, let’s restart SpamAssassin and Postfix

systemctl restart spamassassin.service

systemctl restart postfix.service

Once both services are restarted, let’s perform a GTUBE test from an external email address. We typically use a Gmail account.

Compose a new message with the following subject and no body content.


Once you’ve sent your message, depending on the rules you configured above, you should see this message appear in your Junk folder rather than your inbox.

Written by: taylor

Tagged as: , , , , .

Rate it
Previous post

Similar posts

Post comments (0)

Leave a reply

Your email address will not be published. Required fields are marked *

  • Locally Owned and Operated
  • Independent, Honest, Intuitive, Knowledgeable


Follow us