Page 45 - Mercury Manual.book
P. 45
Mail Filtering Rules 40
How mail filtering works
Mail Filtering Rules
One of Mercury's most powerful features is its ability to perform complex processing on in-
coming mail based on sets of rules that you create. This process, called mail filtering, was
invented for, and pioneered by Pegasus Mail in 1991, and can be used for almost any mail
processing task you can imagine. Three types of mail filtering are available in Mercury/32:
Global filtering You can create exactly one set of global filtering rules, which are applied to
every mail message processed by the Mercury Core Module. If your global filtering rules re-
sult in the message being deleted, or moved to another user, then the core module will make
no further attempt to deliver the message.
Outgoing mail filtering As with global filtering, you can create exactly one set of filtering
rules that will be applied only to messages leaving the server (i.e, outgoing mail). If, as many
organizations do these days, you need to add disclaimer text to the messages leaving your
site, this is the rule set where you will typically do it, using an Insert text fragment rule – but,
of course, you can also do anything else Mercury’s comprehensive rule process suite allows.
General filtering You can have as many general filtering rule sets as you wish, and can bind
them to any address on your system via a FILTER: alias (see the section entitled Aliases for
more information on doing this). Unlike Global filtering rules, general filtering rule sets are
only applied to a message when the core module actually attempts to deliver it to the aliased
address. General filtering rules are always applied after any global filtering rules on your sys-
tem, so if a global filtering rule deletes or moves a message addressed to a FILTER: alias, the
general rule set will never be invoked. It is legitimate to bind a general rule set to an existing,
valid address on your system: doing this will invoke the rule set before delivery occurs, but
will suppress delivery to the address. In order to interpose a filter set and still allow mail to
be delivered to the address, you must add a Copy to user rule action to the rule set, which
makes an unaltered copy of the message in the user's mailbox.
All three types of filtering rule sets are edited using the same interface, and can be created or
maintained using the options on the Mail Filtering submenu of the Mercury Configuration
menu.
How mail filtering works
A rule is activated when a particular condition, or trigger is met within a message. When a
match occurs, the action defined in the rule is applied to the message. This process repeats
until either there are no more rules, or the message is moved to another user's mailbox, or the
message is deleted. You can make multiple rules apply to the same message by giving them
all the same trigger condition: the rules will then be applied in the order they appear in the
rule list, reading from the top down.The trigger condition can be any of the following:
• A simple textual phrase is encountered in the message headers
• A particular regular expression is encountered in the message headers or body
• The sender of the message is a member of one of your distribution lists
• The message has attachments with particular filename or extension parts
• The message is larger or smaller than a specific size
• The message has certain attributes, such as attachments or urgent flags.
• No condition – the rule always triggers when it is encountered.