Adding custom rules - spamassassin

Kevin Miller kevin.miller at
Tue Oct 10 17:23:35 UTC 2017


You have a couple options for black/white listing.  Both are fairly easy.

As Peter mentions, you can create a rule in spamassassin which will add or subtract X points to messages that match.  MailScanner will then act on them via the spam actions and spam score settings in MailScanner.conf (or your customizations in the conf.d directory).

To create custom spamassassin rules, create a text file ending in .cf (, for example) in /etc/mail/spamassassin.  Any file ending in .cf will be processed automatically by spamassassin.  Then, create the rules that you need within that file.

The other option is to use the whitelist or blacklist settings in MailScanner.conf: 
  Is Definitely Spam = %rules-dir%/spam.blacklist.rules
  Is Definitely Not Spam = %rules-dir%/spam.whitelist.rules

Look in the rules directory for examples.

Using a spamassassin rule will let you target very specific patterns which is good if a bunch of spam messages are identical but being sent from multiple different domains, or from an email address from which you don't want to block everything.

Using MailScanner white/black lists allow you to accept or block at the username and/or domain name level.  Much less granular but very effective when you just want to stomp on everything from a particular user or domain.

BTW, on some systems, the default spamassassin rulesets land in /var/lib/spamassassin, not /usr/share/spamassassin, depending on which distro you're using.

Kevin Miller
Network/email Administrator, CBJ MIS Dept.
155 South Seward Street
Juneau, Alaska 99801
Phone: (907) 586-0242, Fax: (907) 586-4588 Registered Linux User No: 307357

-----Original Message-----
From: MailScanner [ at] On Behalf Of Peter H. Lemieux
Sent: Tuesday, October 10, 2017 8:20 AM
To: Koby Peleg Hen
Cc: MailScanner discussion
Subject: Re: Adding custom rules - spamassassin

Usually the local rules go in /etc/mail/spamassasin.  The SA-supplied rules are in /usr/share/spamassassin.  Items in the first directory usually expand the ruleset, though you can override existing rules there as well.  Usually that's done only to adjust the scores given to those pre-existing rules.

I'm not sure what you are asking for though.  Are you looking to create multiple conditions that must be met?  You can use the "meta" directive for that.  In the example you give, there's nothing to distinguish between the two rules, so I can't tell what you're trying to accomplish.

Are you handling mail for multiple domains?  If you're only accepting mail for "," then you can omit the To: part of the rule and just key on the From;.


On 10/10/2017 10:51 AM, Koby Peleg Hen wrote:
> Hello Petter
> Thank you for your answer,
> I already been there, but thank you anyway.
> I have 2 question please :
> 1.where to put it so it can be merge to the other rule in the system 
> and NOT override them
> 2.There is any way to preform specific rule for specific condition like :
>   From * To CheckRuleNo1
>   From * To CheckRuleNo2
>   etc..
> Thank you for your co operation
> Koby Peleg Hen
> On 10/10/17 16:25, Peter H. Lemieux wrote:
>> Start here:
>> Peter
>> On 10/10/2017 07:13 AM, Koby Peleg Hen wrote:
>>> Hello All
>>> I Would like to add a custom rules to spamassassin to prevent 
>>> specific  body / header content.
>>> Please show me a quick example.
>>> Thank you for your co operation
>>> Koby Peleg Hen

MailScanner mailing list
mailscanner at

More information about the MailScanner mailing list