Discussion:
Rules multiple conditions
Marc
2014-03-17 00:04:52 UTC
Permalink
I'm trying to archive email FromOrTo a domain so have the rule:



FromOrTo: *@domain.com <mailto:*@domain.com> /path/to/archive



Which works great.



However, I'd like to exclude a particular address (one for now, so hoping
its easy).



FromOrTo: *@domain.com <mailto:*@domain.com> or Not From: user at domain.com
<mailto:user at domain.com>



How could that work? (I assume the 'Not') won't work in the above line.
What is the correct rule?


Thanks,





Marc



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.mailscanner.info/pipermail/mailscanner/attachments/20140316/d4bd927d/attachment.html
Jerry Benton
2014-03-17 00:55:39 UTC
Permalink
Point the setting to a ruleset file and put it in two rules.?

FromOrTo: user at domain.com /dev/null
FromOrTo: *@domain.com /path/to/archive

This is an All Match rule, so this may or may not work, but it should be easy enough to test.?



--?
Jerry Benton
www.mailborder.com

On March 17, 2014 at 1:46:22 AM, Marc (marc at reidclan.com) wrote:

I?m trying to archive email FromOrTo a domain so have the rule:

?

FromOrTo: *@domain.com /path/to/archive

?

Which works great.

?

However, I?d like to exclude a particular address (one for now, so hoping its easy).

?

FromOrTo: *@domain.com or Not From: user at domain.com

?

How could that work? (I assume the ?Not?) won?t work in the above line.? What is the correct rule?


Thanks,

?

?

Marc

?

--
MailScanner mailing list
mailscanner at lists.mailscanner.info
http://lists.mailscanner.info/mailman/listinfo/mailscanner

Before posting, read http://wiki.mailscanner.info/posting

Support MailScanner development - buy the book off the website!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.mailscanner.info/pipermail/mailscanner/attachments/20140317/feb2a10b/attachment.html
Mark Sapiro
2014-03-17 04:29:21 UTC
Permalink
Post by Marc
However, I'd like to exclude a particular address (one for now, so hoping
its easy).
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 domain.com. 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
regexp.
--
Mark Sapiro <mark at msapiro.net> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
Mark Sapiro
2014-03-17 04:46:51 UTC
Permalink
Post by Mark Sapiro
Even simpler, you can use perl's '!' not operator as in
Ooops. It appears that doesn't work. I thought I'd tested it, but I'd
forgotten to reload MailScanner after changing my test rule.

The negative lookahead rule does work as described in my first reply.
--
Mark Sapiro <mark at msapiro.net> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
Continue reading on narkive:
Loading...