On 2011-10-22 at 23:08 +0100, Colin wrote:
> Say I have the following in /etc/staticroutes
>
> domain1.com: 1.1.1.1
> domain2.com: 2.2.2.2
> domain3.com: 1.1.1.1
>
> Delivery to each domain individually is fine. A message addressed to
> user@??? and user@??? is fine.
>
> A message which contains any user at domain1.com and domain3.com will
> fail as both domains point to the same IP address. Can anyone see an
> obvious reason why these would fail?
Yes.
Look up the documentation for "$domain":
When an address is being routed, or delivered on its own, this variable
contains the domain.
[...]
When more than one address is being delivered at once (for example, several
RCPT commands in one SMTP delivery), $domain is set only if they all have
the same domain. Transports can be restricted to handling only one domain
at a time if the value of $domain is required at transport time - this is
the default for local transports. For further details of the environment in
which local transports are run, see chapter 23.
> #Router
>
> static_route:
> driver = manualroute
> transport = remote_smtp_smart
> route_data = ${lookup{$domain}lsearch{/etc/staticroutes}}
So at this point, the transport can access the host via $route_data.
> #Transport
>
> remote_smtp_smart:
> driver = smtp
> port = 25
> delay_after_cutoff = false
> hosts = ${lookup{$domain}lsearch{/etc/staticroutes}}
> hosts_override
And here you look up the hosts again, but $domain will not be set if
multiple domains are being passed down one connection.
The static_route Router has provided a list of hosts via the
"route_data" option -- you don't need to override it again here. Just
leave off the hosts/hosts_override option to use whatever hosts were
passed into this via the Router which specified to use this Transport.
-Phil