WritingRules in SPAMASSASSIN

For our first rule, let’s start with the simplest type of rules, the basic “body” rule. These rules search the body of the message with a regular expression and if it matches, the corresponding score is assigned. Body rules also include the Subject as the first line of the body content. See [DumpTextPlugin]

Let’s look at a really basic fictitious rule:

describe LOCAL_DEMONSTRATION_RULE 	This is a simple test rule

This rule does a simple case-sensitive search of the body of the email for the string “test” and adds a 0.1 to the score of the email if it finds it. Now, this rule is pretty simple as rules go. It will match “test” but also “testing” and “attest”. The describe statement contains the text which will be placed into the verbose report, if verbose reports are used (this is the default setting for the body, in Spamassassin version 2.5x and upwards).

In regular expressions a \b can be used to indicate where a word-break (anything that isn’t an alphanumeric character or underscore) must exist for a match. Our rule above can be made to not match “testing” or “attest” like so:


The rule can also be made case-insensitive by adding an i to the end, like this:


Now the rule will match any combination of upper or lower case that spells “test” surrounded by word breaks of some form.

Source: WritingRules – SPAMASSASSIN – Apache Software Foundation

WritingRules in SPAMASSASSIN was last modified: June 30th, 2020 by Jovan Stosic

Leave a Reply