[exim] headers_add only if condition

Top Page
Delete this message
Reply to this message
Author: Rob Gunther
Date:  
To: exim-users
Subject: [exim] headers_add only if condition
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}}

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.

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?


Robert G.