Re: [exim] Conditionally removing/rewriting received header …

Pàgina inicial
Delete this message
Reply to this message
Autor: David North
Data:  
A: exim-users
Assumpte: Re: [exim] Conditionally removing/rewriting received header based on destination MX hostname
On 14/12/13 17:03, David North wrote:
> I ran into a problem earlier today sending mail from my phone via Exim 4
> on my server.
>
> My phone has a randomly chosen IPv6 address (within my /64) thanks to
> IPv6's privacy features. The phone's IP has no reverse DNS. It relays
> mail up to my server, which has a static IPv6 address with reverse DNS.
>
> Unfortunately, it seems Google bounce all mail received by their servers
> with *any* IPv6 address in the Received: headers which does not have
> reverse DNS.
>
> Leaving aside how broken this behaviour is, I'm trying to work round it
> in my Exim configuration.
>
> Disabling IPv6 for Exim altogether would be an effective if rather
> brutal and backward-looking option. Disabling IPv6 per target domain is
> also possible and less brutal, but the trouble is the number of them -
> plenty of people use Google Apps for their own domains, so a simple
> regex match on gmail won't cut it.
>
> So what I would like is to have exim do this:
>
> IF message is to be delivered to *.google.com via the remote_smtp transport
>
> THEN delete Received: headers containing IPv6 addresses matching my /64
>
> AND possibly add an X-Received header with the deleted content and some
> pithy remark about Google being idiots.
>
> Is this possible within Exim? Having spent some time with the
> documentation, it looks like the remote_smtp transport has access to the
> target MX hostname in $host, but I can't see a way to conditionally
> drive some header removal/addition from this if $host matches *.google.com.
>
> I could do it in a programming language of my choice invoked via
> transport_filter, but I'd rather not involve a separate process in this
> stage of delivery.


I stuck with it and came up with a solution - replace the dnslookup
router with two like so (most of the router options omitted for brevity):

dnslookup_non_google:
debug_print = "R: dnslookup (non-google) for $local_part@$domain"
ignore_target_hosts = *.google.com : *.googlemail.com
# not no_more, because the google one might take it

dnslookup_google:
debug_print = "R: dnslookup (google) for $local_part@$domain"
# strip received headers to avoid Google's silly IPv6 rules
headers_remove = Received
headers_add = X-Received: Authenticated device belonging to David
North or one of his users
no_more






--
David North | http://www.dnorth.net