Overview

Matching emails

When an email is sent, it consists of two parts: the headers and the body. The body is the part with the actual message; the headers are the part containing information like sender, recipient, date and time of sending, and what server it was sent through, among other things. The Rules for filtering mail work by looking through these headers to see if there is a match with any of the rules. The various options in 'Message with' each examine a different part of the headers.

  • Subject

    Looks in the Subject part of the headers; this is the subject that you see in the Mailbox view.

  • To/CC

    Looks in the 'To' or 'CC' part of the headers. 'To' is the address the mail was sent to; this can be your account, but it can also be an alias, a pop-link you retrieved a mail from, or a subdomain-addressing address. 'CC' means Carbon Copy, and can be used to specify additional recipients of an email. It's combined with 'To' since essentially they mean the same.

  • From

    Looks in the 'From' part of the header. This is used to determine who sent the email, and allows you to sort and filter mail depending on the sender.

  • Any header

    Looks through all the headers. Be careful with this, as there are a lot of headers, including things like servers an email passed through. It is very easy to make a rule that accidentally has a lot more positives than you intended.

  • Envelope

    This is an advanced function. The envelope is the 'real' source of the mail. All the other headers are created by the email client someone uses; the envelope is created by the email server. This is particularly useful for filtering mailing-lists and mails where you are addressed through the 'BCC' (Blind Carbon Copy) field, as there won't be a 'To' field to filter for. When an email is sent as 'BCC', there are no header fields which show the exact address the email was sent to; there are, however, a number of fields added as the email is processed. The delivery process is described in Email Troubleshooting, Common Questions . You can use these extra delivery details to filter emails sent to a 'BCC' address.

  • Advanced

    'Advanced' is not a header; rather, it allows you to filter for anything you want in the headers. For example, if you receive mails that have a very strange character set and you wish to set those aside in another folder, you can use this filter.

    Important: You will need to understand the sieve mail filtering language before you use this filter type, as the contents are passed directly into a sieve "if" clause. If you don't know sieve, do not use this filter type, as it may stop all your rules from working.

  • Always

    This matches any email that comes across this rule. Use this if you want to apply the current rule for all emails that get to this rule.

  • Body

    This will look for the match in the body of the email.

Text patterns

We do support slightly more complicated behaviour than is accessible on the Rules screen, but you need some incantations in the 'Text' field to trigger it.

NOTE: Using any of these forms in the 'Text' field will cause the 'That' drop down to be ignored. Because of this, it will be replaced with a text string next time you load the page.

  • If you specify '|pattern|', then 'pattern' will be treated like a glob pattern, rather than plain text. In a glob pattern, you can use * to match any number of characters, and ? to match a single character.

    The glob match is 'anchored' at the beginning and end of the header, so '|*word*|' is equivalent to "Contains 'word'", and '|word|' is equivalent to "Is exactly 'word'".

  • If you specify '/pattern/', then 'pattern' will be treated like a regular expression pattern, rather than plain text.

    Note that you can just enter a normal regular expression here, you don't have to "double backslash" like you would if you were writing the sieve script directly.

    Note also that POSIX EREs are supported, but NOT PCREs.

    If you don't know what a 'regular expression' is, you're probably better off sticking with glob patterns. If you'd like to learn about regular expressions, you can try consulting Wikipedia.

  • If you specify '!|pattern|' or '!/pattern/', then pattern is treated like a glob or regular expression as appropriate, and the ENTIRE RULE is negated.

    For example, if you select 'Any Header', and specify '!|*example*|' then this will only match against messages that do not contain the word 'example' in any header. If a single header contains 'example' then the rule will not match against that message.

    Note that the '*' at either end are important if you just want to test that some text doesn't occur anywhere in the specified headers.

    Likewise, remember that only THIS rule is negated. For example, if you attempt to build a whitelist with multiple reject rules, 'From' - '!|*myfriend*|' and 'From' - '!|*myotherfriend*|' then all mail will be rejected. The first rule will reject mail from 'myotherfriend@example.com', and the second rule will reject mail from 'myfriend@example.com'. That's bad!

    Be careful using this. It's easy to accidentally filter all your mail away, if you haven't considered all the angles.

Rule order

The following screens currently generate rules that appear in the final sieve script for your account.

  • Spam/Virus Protection: All settings (except Possible Spam settings) produce sieve code.

  • Personalities: Sent Items on SMTP setting (currently only on Beta server) produces sieve code.

  • POP Links: File into folder (if different than Inbox) produces sieve code.

  • Define Rules: All settings produce sieve code.

The screens above automatically create sieve code in the following order. If no rule is activated, the message by default is filed in the Inbox by the implicit keep.

  1. SMTP filing: Each Personality which has SMTP filing to folder active generates sieve code examining the x-resolved-to header looking for +personalitysentitem- followed by a unique number for that personality in your account. There is one of these clauses per Personality which has SMTP filing active. This code is ignored on incoming external messages, and is only executed when the account sends a message. Sieve execution is stopped after the filing action.

  2. Secret word: If found in "to", "cc", or "subject", then the following six sections are skipped: Rejecting emails, Maximum size, Whitelisting, Backscatter filtering, Definite Spam, and Probable Spam.

  3. Rejecting emails clauses: If a match is found, the message is either rejected with the bounce message "Message bounced by server content filter" or silently discarded, and sieve execution is stopped.

  4. Maximum size: If the message size is exceeded, the message is rejected with the bounce message "Message not delivered; size over limit accepted by recipient"; if the settings are "Move to folder" and the Folder is set to <Reject> the message is silently discarded, or if the Folder is set otherwise the message is filed in that folder. If the message size was exceeded, sieve execution is stopped after these actions.

  5. Whitelisting: If the sender is whitelisted (exact address or *@domain appears in the online address book), then the following three sections (Backscatter filtering, Definite Spam, and Probable Spam) are skipped.

  6. Backscatter filtering: If the sender is not whitelisted by the address book, then the backscatter rules are executed, and sieve execution is stopped after these actions.

  7. Definite Spam: If the sender is not whitelisted by the address book, then the Definite Spam rule is executed (which can discard the message), and sieve execution is stopped after these actions.

  8. Probable Spam: If the sender is not whitelisted by the address book, then the Probable Spam rule is executed, which can file the message (normally in Junk Mail), and sieve execution is stopped after these actions.

  9. Bypass File into Folders for Mailing Lists: If this parameter is found in "TO" or "CC", then the next two sections (File into folders and POP links filing) are skipped.

  10. File into folders: If this test is satisfied, the message (optionally flagged) is filed into a specified folder and the next section (POP links filing) is skipped.

  11. POP links filing: If the message was obtained from a POP link, then the filing rule on the POP Links screen is executed, and sieve execution continues to the next step.

  12. Automatic notification (vacation message): If the incoming message was sent to an address set up on the Personalities screen, then the vacation message is executed, and sieve execution continues to the next step.

  13. Forwarding: The forwarding rules are executed.