MailScanner blacklisting and whitelisting smtp addresses

Lets take a look at what it takes to create whitelists and blacklists rule sets on MailScanner based Email gateways. We assume MailScanner is installed on CentOS version 7, but it should also work on other Linux Distributions.

Whitelist SMTP address
1. Create a new file /etc/MailScanner/rules/spam.whitelist.rules

vi /etc/MailScanner/rules/spam.whitelist.rules
FromOrTo:	default		no
FromOrTo: 	 test.com 	yes
FromOrTo: 	 test@test.com 	yes

2. Configure MailScanner to handle all messages in the whitelist as spam

vi /etc/MailScanner/MailScanner.conf
Replace this line:
#Is Definitely Not Spam = no
with 
Is Definitely Not Spam = %rules-dir%/spam.whitelist.rules

3. Restart MailScanner

systemctl restart MailScanner 

Blacklist SMTP address
1. Create a new file /etc/MailScanner/rules/spam.blacklist.rules

vi /etc/MailScanner/rules/spam.blacklist.rules
FromOrTo: 	 test123.com 	yes
FromOrTo: 	 test123@test123.com 	yes
FromOrTo: default no

2. Configure MailScanner to handle all messages in the blacklist as spam

vi /etc/MailScanner/MailScanner.conf
Replace this line:
Is Definitely Spam = no
 
with this:
Is Definitely Spam = %rules-dir%/spam.blacklist.rules

3. Restart MailScanner

systemctl restart MailScanner 

If you want to handle all messages from blacklisted e-mail addresses like high scoring spam, change this property:

Definite Spam Is High Scoring = yes