Page 46 - Mercury Manual.book
P. 46
41 Mail Filtering Rules
How mail filtering works
When performing text matching within a message, you can perform two types of matching to
detect the trigger text – simple header matching, where Mercury looks for the trigger text in
selected common headers in the message; and regular expression matching, which allows
you to set up complex pattern-matching criteria in the message headers only, in both the mes-
sage headers and message body, or only in the message body.
To create a rule, highlight the item in the rule list before which you want the new rule to ap-
pear, then click the button on the left-hand side of the dialog that represents the type of rule
you want to create. A rule editor window will open, in which you tell Mercury what condi-
tions should trigger the rule, and what action the rule should take when it is triggered. The
various trigger types and their options are described below.
Standard header match (the Headers button) creates a rule which simply matches text in any
of a set of predefined message headers. Click the controls representing the fields you want
Mercury to check for the trigger text. You can check more than one control if you want Mer-
cury to examine multiple fields. So, if you want Mercury to check in both the From and To
fields for a string, you should check both controls. Mercury normally searches for the text
you enter anywhere in the header, so if you enter “bed”, the rule would trigger on bed,
tabbed, albedo, or any word containing bed. If you want the rule to trigger only when the field
matches the trigger text exactly, check the control labelled Exact match. So, if this control
were checked and the trigger text were Subscribe, then the text Please subscribe me would
not cause the rule to trigger. The trigger text is not case-sensitive, so SUBSCRIBE and Sub-
scribe are always regarded as a match.
Regular expression match (the Expression button) creates a rule that uses an arbitrary ex- Mercury’s regular expres-
sion engine predates
pression to match lines in the messages. The scope controls specify in which parts of the mes- Posix, Perl and other
sage Mercury should try to match your expression: you can have your expression checked regex implementations, so
if you are used to those
against only the message headers, only the message body, or against the entire message. formats, you may find it a
Matching against the entire message or against the message body can slow down the process little idiosyncratic.
of processing messages dramatically – performance is affected by having a single rule that
does a message body check, although subsequent rules will not slow the process down fur-
ther. The trigger text for a regular expression rule contains the text or expression Mercury
should attempt to find in your message. The text is always case-insensitive – so to Mercury, Mercury regular expres-
NOVELL@suvm is the same as Novell@SUVM. It is very important to understand that reg- sions always start match-
ular expression matching always begins at the start of the line. Your expression can contain ing from the start of a line.
the following special characters for pattern matching
:
* Matches any number of characters
? Matches any single character (but not zero characters)
[ ] Defines a set of characters to match (see below).
+ Matches any number of recurrences of the last character or
pattern that was matched.
Sets of characters can be entered literally – for example [abcd1234], or you can specify
ranges of characters using a hyphen, like this: [a-d1-4] (which would match any of
abcd or 1234). You can negate a set (tell Mercury only to match characters NOT present
in the set) by using a caret (^) as the first character in the set. If you need to search for a literal
occurrence of a special character, you must enter it as a set expression – so, to search for an
asterisk, you would enter [*]. Remember that regular expressions begin at the start of a
line, so if you want to match text anywhere in a line, the first character in the expression must
be a *.