Re: [exim] headers_add only if condition

Página Principal
Apagar esta mensagem
Responder a esta mensagem
Autor: Ian Eiloart
Data:  
Para: Rob Gunther
CC: <exim-users@exim.org>
Assunto: Re: [exim] headers_add only if condition

On 15 Mar 2013, at 10:34, Rob Gunther <redrob@???> wrote:

> I am working on an SRS/SPF solution, I have created a router that does will
> re-write the from envelope only if the sending domain has an SPF entry.
>
> I'm using this:
>
> condition = ${if match{${lookup dnsdb{>\n;
> defer_never,txt=$domain}}}{\N(?m)^v=spf1\s\N} {1}{0}}


You might also want to check for an SPF record, as well as an SPF string in a TXT record. But the problem here is using $domain (The recipient domain) rather than $sender_address_domain

If you have Exim compiled with SPF support (see https://github.com/Exim/exim/blob/master/doc/doc-txt/experimental-spec.txt) , then you could put this into an ACL with a much simpler test like:

spf = none

The docs say "none" means "The queried domain does not publish SPF records"


> The condition is working, if the domain has no TXT record then it does
> nothing to the sender address.
>
> The problem I am having is I am also adding a header to the router:
>
> headers_add = "X-SRS: Sender address rewritten from <$sender_address> to
> <${quote_local_part:${local_part:$address_data}}@${domain:$address_data}>"
>
> That header is being added to every message, even if the sender address was
> not altered. I thought it would only do that if the conditions(s) for the
> router were met but apparently not.


I think you may need to put the conditions before the headers_add directive. Certainly logging directives are executed regardless of later conditions.

> So 2 questions:
>
> 1) Can I fix this easily with some command?
> 2) I think I can do it by wrapping a condition into the headers_add option
> (based on some searching), that option seems complex to figure out - but
> more importantly would the router do the DNS check two times? Once for the
> condition on the router itself and again to figure out if the headers_add
> would be added?


I think the DNS lookup is cached. So it would not be performed twice, but the result should be available.

>
> Robert G.
> --
> ## List details at https://lists.exim.org/mailman/listinfo/exim-users
> ## Exim details at http://www.exim.org/
> ## Please use the Wiki with this list - http://wiki.exim.org/


--
Ian Eiloart
Postmaster, University of Sussex
+44 (0) 1273 87-3148