Here's the solution I found, with help from Philip Hazel:
(Original question below)
On the last server in the chain, create an 'unknown' transport and director:
unknown_transport:
driver = smtp
hosts = 172.16.3.5 # this is the first host in the chain
gethostbyname # We don't have internal DNS
unknown:
driver = smartuser
condition = ${if and {{eq
{${lookup{${local_part:$h_sender:}}lsearch{/etc/passwd}{$value}{0}}}{0}}{!match{$sender_rcvhost}{.*\[172\.16\.3\.5\].*}}}{1}{}}
transport = unknown_transport
no_verify #optional, but needed in our case.
The 2nd half of the condition (the match) prevents looping when mail to an unknown user comes in from
outside. The first half allows local users to mail anybody in the domain. if it turns out to be a
non-existant user, then clause 2 will pick it up when the message arrives back at the end of the chain.
Note that in this case both addresses involved (172.16.3.5) are the same. If you'd have more than two
servers, the last address changes to that of the one-but-last in the chain.
In this way, we won't need to keep user databases in sync between the various mail servers.
No doubt there's a more elegant way of doing this. I'm open to suggestions. One day we'll look at LDAP. But
for now, this works.
Rolf Habing
Systems and Networking
Canterbury Christ Church University College
------------
Rolf Habing wrote:
> Hello,
>
> I'm in the process of moving our current mail system from sendmail to
> imap, and at the same time splitting the current single mailbox server
> into two, with option of introducing more mailbox servers at a later
> date.
>
> All mail for the local domain comes in on server 1. If the local user is
> unknown, then an unknown_transport moves it to the next server. This
> works beautifully.
>
> The problem I encounter is when people on server 2 want to mail server 1
> people. The obvious thing to do is probably a table of which user is on
> what server, and route accordingly. However, I'd like to get away from
> large lists as much as possible and am looking for a listless solution.
> (Each server hosts +10,000 users.)
>
> Introducing an unknown transport on server 2 back to server 1 would
> create a mail loop.
>
> Is there any way I can achieve this routing back without causing a loop?
>
> I guess that a test could be used where if the sender is a local user
> and the message has not already been received/handled by server 1, then
> the unknown transport could be applied, and otherwise the message would
> be bounced back to the sender (unknown user on any local system).
> However, I cannot see how to implement such a test.
>
> Thanks for any help/suggestions,
>
> Rolf Habing
> Systems and Networking
> Canterbury Christ Church University College
>
> --
> ## List details at http://www.exim.org/mailman/listinfo/exim-users Exim details at http://www.exim.org/ ##