Knowledgebase

status_loader

Adding cutom SpamAssassin rules

Question / Problem

How can I add custom rules?

Answer / Solution

To add your own SpamAssassin rules, please create a plain text file that has the file extension .cf and place it into the configuration directory "C:\ProgramData\JAM Software\spamdService\sa-config". You can now add your own rules using the following syntax:
header  JAM_ERECTION Subject =~ /e.?r.?e.?c.?t.?[i1|l!].?[o0].?n/i
describe  JAM_ERECTION Subject contains "erection"
score  JAM_ERECTION 1.0

This will create a rule which catches various spellings of the word "erection" in the subject of a mail. For more information on writing custom rules, please refer to the following topic in the official SpamAssassin Wiki: https://cwiki.apache.org/confluence/display/SPAMASSASSIN/WritingRules

Alternatively you can also define your rules in the "user_prefs" configuration file which is located in the user profile directory. For a regular user this is the following directory:
%userprofile%\.spamassassin
When executing SpamAssassin using the Windows system service account (which is the default when using SpamAssassin in a Box for example) the file will typically be located at the following directory:
"C:\Windows\System32\config\systemprofile\.spamassassin"

When using the SpamAssassin daemon (spamd.exe) for spam filtering, testing rules in the "user_prefs" file has the advantage that its contents are read for each mail and not only at the start of the process. This way you won't have to stop and start the SpamAssassin daemon each time you want to check if a certain change to your custom rule has the desired effect. If the rule is working as intended you can still copy it to a .cf file in the configuration directory (<%SACONFIGPATH%>). This is a good practice as a huge "user_prefs" file would decrease performance of the SpamAssassin daemon.

Need further help getting started?

You did not find what you were looking for? Please contact us so we can provide an answer to your question.

Contact Form