Rules multiple conditions

Mark Sapiro mark at
Mon Mar 17 04:29:21 GMT 2014

Marc wrote:
> However, I'd like to exclude a particular address (one for now, so hoping
> its easy).
> FromOrTo: *  or Not From: user at
> How could that work? (I assume the 'Not') won't work in the above line.
> What is the correct rule?

First of all, 'or' is not allowed in "two condition" rules. Only 'and'
is allowed which is what you want anyway.

And yes, 'Not' doesn't work, but you can do this using perl regular
expressions with something like

FromOrTo: /\@domain\.com$/ and From: /^(?!user\@domain\.com$)/

Note that if the second condition is going to be a perl /.../ regexp,
the first must be also. The second condition uses negative lookahead.
(?!xxx) matches if and only if the current position is not followed by
'xxx'. In this case we match the beginning of the string, not followed
by exactly user at The $ inside the lookahead matches the end
of string and it must be inside because the lookahead doesn't advance
the string. Also the @ and . are escaped so they don't have special meaning.

Even simpler, you can use perl's '!' not operator as in

FromOrTo: /\@domain\.com$/ and From: !/^user\@domain\.com$/

Here again, for this to work, the first condition must also be a perl

Mark Sapiro <mark at>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

More information about the MailScanner mailing list