Page 51 - Mercury Manual.book
P. 51

Mail Filtering Rules  46
                                                                                  Advanced rule processing options



                                    more rules (in which case rule processing terminates), or a rule triggers that has the Return
                                    from call action (in which case processing resumes at the rule following the one which initi-
                                    ated the call).

                                    Gotos  A goto is like a call, in that it simply transfers processing to a label anywhere else in
                                    the rule set. The difference is that you cannot return from a goto - the transfer of processing
                                    is final. Gotos are primarily useful when implementing complex logical operations.

                                    Creating logical operations in your rule sets
                                    Often, you may only want to apply a rule to a message if all of a number of conditions are
                                    matched, or if any one or more of a number of conditions apply. This kind of operation is
                                    known as a logical operation (it is also known by the technical name Boolean operation).
                                    Mercury implements logical operations by a combination of rule order and flow control struc-
                                    tures. Before reading about logical operations, we strongly suggest you read the section on
                                    flow control, above.

                                    Tip When using logical operations in rule sets, it is very important to remember that rules are
                                    always applied to the message in the order in which they appear in the rule list editor, starting
                                    at the top of the list and working through to the bottom.

                                    Applying a rule when any of several conditions is met (logical OR)  “The simplest logical op-
                                    eration you can create in a rule set is that where an action is applied if one or more conditions
                                    is satisfied (i.e, condition1 OR condition2 OR condition3 and so on). You can create
                                    this kind of operation simply by creating multiple rules matching on different conditions, all
                                    executing the same action. For example, say you want to copy a message to an alternative
                                    account if the subject contains the word order, or if the subject contains the word invoice
                                    or if the To: field contains the address orders@foo.bar.com - you would add the following
                                    three rules to your rule set

                                       If "Subject" field contains "order" then copy to user "orders"
                                       If "Subject" field contains "invoice" then copy to user "orders"
                                       If "To" field contains "orders@foo.bar.com" then copy to user "orders"

                                    Notice that the action is the same in each case. In cases where repeated application of the rule
                                    action might not be desirable (for instance, copying messages to a folder, in which case you
                                    could get multiple copies of the message), more complex combinations of goto and call state-
                                    ments can be used to achieve the same effect - for example, like this:

                                       If "Subject" field contains "order" then goto label "copy message"
                                       If "Subject" field contains "invoice" then goto label "copy message"
                                       If "To" field contains "orders@foo.bar.com" then goto label "copy message"
                                       label "Next label"
                                       [... other rules ...]
                                       Label "copy message"
                                       Always copy to user "orders"
                                       Always goto label "next label"

                                    In this example, any of the conditions will transfer control to the rule that actually copies the
                                    message, which in turn immediately transfers control to the first rule after the group, so you
                                    will only ever get one copy of the message.

                                    Applying a rule only if all specified conditions are met (logical AND) Mercury offers three
                                    ways of applying a rule only if all of a set of conditons apply. The simplest way is to create
                                    multiple rules where the action for every rule but the last is Logical AND; the last rule in the
   46   47   48   49   50   51   52   53   54   55   56