Re: [exim] Discard mail to certain recipients if the subject…

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Mike Brudenell
Ημερομηνία:  
Προς: Exim Users
Αντικείμενο: Re: [exim] Discard mail to certain recipients if the subject matches a string
Hi,

On 6 April 2017 at 11:57, Александр Кириллов <nevis2us@???> wrote:

> Thanks for the pointers, Chris! It worked!
> This simple router did the trick:
>
> discard_notifications:
> driver = redirect
> domains = <domain literal>
> condition = ${if match {$h_subject:}{Commit.by}}
> data = :blackhole:
>


Do note that the router you describe here doesn't actually do what you
originally asked us about! In your original question you asked blocking the
message to some specific recipients (implying the local part to the left of
the "@" in the address plays a part in deciding whether to block or not).
The above router doesn't check the local part at all, but only looks at the
domain name of the recipient address.

I probably spent more time trying to figure out how to match a single space
> in "Commit by" and didn't succeed yet. This is a minor thing but I would
> like to know the answer and go to bed a happy man. )
>


The "." you've put in your pattern doesn't mean "a single space" but means
"any single character". So your pattern "Commit.by" will also trigger on
"Commit-by".

If you mean:

- a single space then just type a single space between the words;
- any one whitespace character (including tabs, newlines, etc) then use
"\s" instead.

Also not that you've not tied your pattern to the start or end of the input
string. That means it will also match on things like "Mike Commit by". If
the "Commit by" always appears:

- at the very start of the Subject text when tie it to the start in your
pattern: "^Commit by"
- at the start of your Subject text but might have leading whitespace
characters before it then use "^\s*Commit by"

Finally, remember that *match* is case-sensitive by default, so if you
might get Subject lines with either an upper- or lowercase "C" then you
need to turn on case-insensitive matching:

- (?i)Commit by
- ^(?i)Commit by

and so on.

Cheers,
Mike B-)

--
Systems Administrator & Change Manager
IT Services, University of York, Heslington, York YO10 5DD, UK
Tel: +44-(0)1904-323811

Web: www.york.ac.uk/it-services
Disclaimer: www.york.ac.uk/docs/disclaimer/email.htm