Rules using regular expressions

Normally, rules for processing email look for text that is "equal to" or "contains" or "starts with" a certain value. However, we also support more complicated matching using globs or regular expressions.

These advanced modes are automatically enabled if you enter a value string of a certain format, regardless of what the match type is currently set to.

Glob patterns

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 searched text, so |*word*| is equivalent to "contains word", and |word| is equivalent to "is word".

Regular expressions

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, there are many good resources to be found on the web.


If you specify !|pattern| or !/pattern/, then pattern is treated like a glob or regular expression as appropriate, and the entire rule is negated.

Be careful using this. It's easy to accidentally filter all your mail away, if you haven't considered all the angles. Remember that only THIS rule is negated. If you attempt to build a whitelist with multiple discard rules, it's easy to end up discarding all mail. For example, suppose you had the following two discard rules:

All mail would be rejected. The first rule will discard mail from "", and the second rule will discard mail from "". That's probably not what you want!

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.