User Tools

Site Tools


reference:spamrules_manylinks

Spamrules example - increase spam score if there are many links in the email

This script is for the case where you to increase the spamminess of emails where the email contains many links - in this case we'll say if the email contains 10 or more links. Note that we do not necessarily recommend that you do this as it is not a very good indicator of spam, and will probably catch a lot of newsletter type emails, but it is something we've been asked for, so here it is.

Add the following to the spamrules_userchecks.txt file. This script file only gets processed on incoming messages (the spamrules_localmail.txt script ends the processing of locally sent messages)

DefineRule "ManyLinks" 1 "Rule to add score for emails with many links"
${URLCount} = 0
ForEach URL LoopUrl
      ${URLCount} += 1
EndFor
If ${URLCount} >= 10
      ${Score} += 50 [ManyLinks]
EndIf

When the message contains 20 links or more, then the spam filter will add '50' onto the spam score (the default threshold for messages to be marked as spam is 100) - you can alter the 50 in the ${Score} += line as appropriate for your requirements.

This is a more complex rule as the spamfilter does not automatically know how many links there are, so the ForEach URL loop counts the number of URLs in the message, and then the subsequent If statement checks the resulting count.

reference/spamrules_manylinks.txt · Last modified: 2018/11/14 10:45 by 127.0.0.1