Hi, Patrick -
On 14 June 2017 at 22:01, Patrick Porteous <patrick.porteous@???>
wrote:
> Here is an example of my router setup with comments on what errors I
> receive in each case:
>
> localuser_filter:
> driver = accept
> transport = local_spam_delivery
> condition = ${lookup {Spam} lsearch{/etc/exim/banned_subjects}{yes}{no}}
> # This works if the word Spam is anywhere in the message.
> condition = ${if match{$h_Subject:}{[Spam]}{yes}{no}} # This works if
> the word Spam is in the subject.
> condition = ${lookup {$h_Subject} wildlsearch{/etc/exim/banned_subjects}{yes}{no}}
> # This fails and gives me the following error.
>
Double-check that the above does what you want as I have a feeling there
might be some problems with it…
- *condition* is a precondition, and all preconditions listed for a
router must evaluate to true for the router to run. So with these three
preconditions you'll therefore need *all three* to pass; is that what
you're wanting/expecting?
- I keep looking at the first *condition* wondering if I'm missing
something… your comment says it matches if the word Spam is anywhere in the
message. I'm looking at it and thinking it's actually looking for the
string constant "Spam" to see if it appears in the your
/etc/exim/banned_subjects file. That is, not consulting the message content
at all?
- The second *condition* also seems a bit suspect… the *match* expansion
condition takes a regular expression as its second argument. Here you have
"[Spam]" which is a character class that matches a single character drawn
from the set "S", "p", "a" or "m". So if the subject text contains any one
of these four characters the condition will match. This doesn't seem to be
what you want!
- Also remember that *match* is case-sensitive, so you probably want to
switch to case-insensitive matching by adding "(?i)" to the start of the
pattern.
- The third *condition* also has an error in that you're missing the ":"
from the end of the "$h_Subject
> Error:
> failed to expand condition "${if and{{bool_lax{NULL}}{bool_lax{${lookup
> {$h_Subject} wildlsearch{/etc/exim/banned_subjects}{yes}{no}}}}}}" for
> localuser_filter router: missing lookup type inside "and{...}" condition
> *** The last condition is what I am trying to accomplish.
>
I don't understand how the condition logged as failing to expand matches
what you have in the file, unless it's some sort of internal representation
of yours.
In which case you might find that adding the missing ":" to the end of the
"$h_subject" improves matters: the *Specification* states that (with
emphasis mine):
Note that the name *must be terminated by colon or white space*, because it
may contain a wide variety of characters. *Note also that braces must not
be used*.
So it might be that without the terminating ":" the variable name is
including the final "}" and throwing out your matched braces?
I am doing this on a virtual host with multiple domains without local
> users. The user accounts are in a database. I'm trying to avoid filtering
> using the .forward file in each user directory and do this system wide
> instead.
>
It's many years since I've used a system filter but I'd suggest taking
Ian's advice and checking that out as an alternative way of doing this.
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