Weblog entry #47 for lee

Routing around multiple-domain restrictions
Posted by lee on Wed 5 Sep 2012 at 23:53
Tags: ,

If you attempt to send an email to multiple addresses that are handled by google's email servers, but that have multiple domains, only the mail for one of the domains will be accepted.

All the other addresses will receive a temporary rejection message:

451-4.3.0 Multiple destination domains per transaction is unsupported.  Please
451 4.3.0 try again.  random.string

What happens next is up to the logic of the server sending the mail. It'll try sending the messages to the next in the MX priority list - which for google-handled domains are going to be the same. And again, all but one of the delivery domains will get rejected.

I've yet to see a mail bounce as a result of this, but for mails with many different domains I've seen deliveries hit their retry limits and hang around on the mail queue for over an hour. Sub-optimal. A web-search for "Multiple destination domains per transaction is unsupported" will likely locate a few annoyed mail-admins.

You can work around this in Exim. Exim has a transport option "multi_domain" that, when set to false, prevents multiple domains from being delivered per transaction. So you need to configure mail to route all google-handled domains via a transport that has this set.

First, set-up a new transport called "remote_smtp_single_domain" - this should be the same as your existing remote_smtp transport, but with "multi_domain = false" /etc/exim4/conf.d/transport/40_temp_single_domain

  debug_print = "T: remote_smtp_single_domain for $local_part@$domain"
  driver = smtp
  multi_domain = false

Then add a new router just before your dnslookup router /etc/exim4/conf.d/router/180_temp_single_domain

  debug_print = "R: dnslookup_single_domain for $local_part@$domain"
  driver = dnslookup
  domains = ! +local_domains : ! +relay_to_domains
  condition = ${if forany{${lookup dnsdb{>: mxh=$domain}}}{match_domain{$item}{+single_domain_mx}}}
  transport = remote_smtp_single_domain
  same_domain_copy_routing = yes

This will cause any domain with an MX record in the domain list "single_domain_mx" to use the new transport.

The easiest way to add the domain list is to add it to your main config, as below. /etc/exim4/conf.d/main/10_temp_single_domain

domainlist single_domain_mx = aspmx.l.google.com : gmail-smtp-in.l.google.com


Comments on this Entry

Posted by Anonymous (70.36.xx.xx) on Thu 2 May 2013 at 22:30
Thank you very much! Completely silly problem to have to rectify, but happily this worked exactly as it should.

[ Parent | Reply to this comment ]