wiki:CustomRules

Creating Custom Rules for SpamAssassin

SpamAssassin includes hundreds of very useful rules for detecting spam (and a few for identifying non-spam), and there are third-party rulesets like the ones produced by the SpamAssassin Rules Emporium (SARE) that fill many of the gaps, but if you've got an idea for a custom rule of your own you can find out more about how to do so here.

In addition to what you learn from the SpamAssassin documentation, there are three things you need to keep in mind when writing rules for a Maia Mailguard site:

  1. Remember to include a 'describe' line with any new rule that you

create, explaining (in 80 characters or less) what a rule hit means, so that Maia can display this in the spam report portion of the mail viewer. This is a 'best practice' issue for SpamAssassin rule writers--they should all be doing this anyway, but some of the third-party rule-writers are sloppy and don't bother with this step. Maia ignores rules that lack 'describe' lines, since it can't know whether those rules were just sub-rules intended to be used as components of a larger meta-rule.

  1. Remember to run the load-sa-rules.pl script after adding new rules,

so that Maia becomes aware of them. SpamAssassin will gladly use them even if you don't do this, but for Maia to show them in the spam report they need to be known to Maia as well. This also allows Maia to track the performance of a given rule.

  1. Remember to restart (not reload!) amavisd-maia after making rule

changes, because amavisd-maia preloads and precompiles the SpamAssassin rules at start-up in order to avoid having to do so every time a mail item is scanned.


Back to FAQ

Last modified 15 years ago Last modified on May 8, 2008, 2:28:48 PM