You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Writing and Testing New Rules

Perhaps the rule you want has already been written – check out the collection of custom rules at SpamAssassinRules.

It's possible to modify existing rules or their scores, or even write your own. Matt Kettler has written "A straightforward guide to writing your own add-on rules for SpamAssassin", at http://mywebpages.comcast.net/mkettler/sa/SA-rules-howto.txt . It covers the syntax, scoring, and advanced techniques.

If you wish to change the score from the default for a single user, add a line like this to that user's ~/.spamassassin/user_prefs file:

    score NAME_OF_TEST 3.0 

This would be most appropriate if that one user is (for example) a bankruptcy lawyer, and needs to see all email dealing with bankruptcies. This user's ~/.spamassassin/user_prefs file would then contain score modifications for those tests that otherwise might flag his client's emails.

If you need to change the score for system-wide processing, create this type of line in your /etc/mail/spamassassin/local.cf or /etc/spamassassin/local.cf file depending on your installation (or any *.cf file in that directory). This is needed from time to time when a network black list used by SA stops functioning, and you need to turn off that specific test by setting its score to zero.

Most systems do not allow new rules to be defined in user_prefs files – they need to go into local.cf or at least that file's directory.

The custom rule writing wiki at http://www.exit0.us/ is an excellent resource, which includes guidance on almost every aspect of rule writing, testing, and implementation. If that site is down, look for Matt Kettler's HOWTO document at http://mywebpages.comcast.net/mkettler/sa/SA-rules-howto.txt and Chriss Santerre's guides at http://www.merchantsoverseas.com/wwwroot/gorilla/sa_rules.htm

The SA development team assigns scores to the distribution set of rules when we do a major release using the GeneticAlgorithm. Some details on how we do that are in RescoringProcess.

If you write custom rules, you really should test them using a hand-classified set of mail messages divided into spam and non-spam collections – see HandClassifiedCorpora – and the mass-check tool – see MassCheck.

If you have questions concerning rules, or want help testing rules against others' corpora, it's appropriate to post your rules (or attempts) to the SA-Talk list.

Once you've written and tested a few rules, consider sharing them with us at SpamAssassinRules.


  • No labels