User Tools

Site Tools


reference:spamrules_statement_ifmatch

Spam Filter Rules: IfMatch

Statement IfMatch
Version 2.1.7+
Purpose Allows you to perform a regular or substring match on a variable or part of the message being processed

IfMatch statements require a data parameter and a search value, in the format

IfMatch <data> <search>

The IfMatch statement must be terminated with an EndIf and may contain an Else statement, just like the If statement.

Data

Parameter name Description Version
${variable} Allows you to search a variable's content 2.1.7
text This searches any plain text part of the message, but does not search attachments 2.1.7
texta This performs the same task as text, but also searches plain text attachments 2.1.7
body This searches any plain text or HTML part of the message. HTML parts have the HTML tags stripped out and are converted to plain text before searching them.2.1.7
bodya This performs the same task as body, but also searches plain text attachments 2.1.7
anytext This performs the same task as body, but also searches the subject line 2.1.7
anytexta This performs the same task as bodya, but also searches the subject line 2.1.7
htmlsource This searches the raw HTML source of the message 2.1.7
htmlsourcea This performs the same task as htmlsource, but also searches plain text attachments 2.1.7
htmltext This searches the text of any HTML parts of the message, after stripping out tags and converting HTML to plain text 2.1.7
htmltexta This performs the same task as htmltext, but also searches plain text attachments 2.1.7
raw-header This searches the entire message header, without any decoding being performed 2.1.7
header This searches the entire message header, with any MIME encoded header lines being decoded first 2.1.7
tag This searches all the HTML tags in the message 2.1.7
rawurl This searches all the URLs in the message in the form they are in the message 2.1.7
url This searches all the URLs in the message after they have been decoded (e.g. %xx encodings have been converted to the actual character) 2.1.7
rcpt This searches all the recipients of the message that VPOP3 knows about (i.e. all recipients in the SMTP envelope, or all recipients which VPOP3 thinks the message is for) 2.1.7
senderip This allows you to check if the sender's IP address is local or remote (test for 'local' or 'remote') 2.1.7
protocol This allows you to check whether VPOP3 received the message using SMTP or POP3 (test for 'smtp' or 'pop3') 2.1.7
whitelist This allows you to see if the search text is in the spam whitelist 2.1.7
blacklist This allows you to see if the search text is in the spam blacklist 2.1.7
<headername> This lets you search a specific field in the message header. Any header name can be used. Any MIME encoded header lines will be decoded before searching them. The header name should be typed without the angle brackets (<>).2.1.7
Raw-<headername> This lets you search a specific field in the message header. Any header name can be used. MIME encoded header lines will not be decoded before searching them. The header name should be typed without the angle brackets (<>). 2.1.7
attachment This searches all the attachment filenames in the message 2.1.11
rawmessage This lets you search through the first 10kB of the raw, undecoded message content.2.2.1
rawmessageall This lets you search through the entire raw, undecoded message content. This should be used with caution as it may make the spam filter very slow if large attachments are being received.2.2.1

The search parameter to the IfMatch statement can either be a regular expression or a simple case insensitive substring search string.

You should put quotes around the text or Perl Compatible Regular Expression (PCRE) to search for.

To specify a regular expression surround it with '/' characters, otherwise VPOP3 will do a single case insensitive substring search.

With regular expressions, it will normally do a case sensitive search, treating the entire search data as a single line. You can modify this behaviour by adding characters after the final '/' character:

i The search will be case insensitive
m The search will treat the input data as multiline data – this means that the $ and ^ characters match at the start and end of a line rather than the start and end of the entire data
n An empty string is not considered to be a valid match if this option is set. For example, without this option set, a match of a?b? will always match, but may match the empty string at the start of the search string.
s The search will let the . (dot) character match a newline character as well as other characters
x Whitespace characters in the search pattern are ignored except when escaped or within a character class
A The pattern is forced to be 'anchored' to the start of the search string
D The dollar character matches only at the end of the search string. Without this, it can also match immediately before the final character if it is a newline character.
U The search will be “ungreedy” instead of the default mode of greedy.

Example

This following example will perform a case insensitive regular expression search of the Subject line of the message header to see if it contains the text hello anywhere.

IfMatch subject "/.*hello.*/i"
# Statements
EndIf

The example above does not need a regular expression and could also be achieved with a substring search, like so:

IfMatch subject "hello"
# Statements
EndIf

This following example uses a regular expression to check whether a Cc header is present

IfMatch cc "/./"
# Statements
EndIf
reference/spamrules_statement_ifmatch.txt · Last modified: 2018/11/14 10:45 by 127.0.0.1