[exim] Problem with mail loops

Top Page
Delete this message
Reply to this message
Author: Marten Lehmann
Date:  
To: exim-users
Subject: [exim] Problem with mail loops
Hello,

I have a problem with our exim setup, because mails that should delivered
locally are delivered externally. This only happens in a special case:

MX 1: server of our customer doing some spam checking and then forwarding to:
MX 2: our mailserver

We have the following router (beside others):

external:
driver = manualroute
domains = ! @mx_primary
transport = remote_smtp
route_list = * out.mailserver.com
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
no_more

So in the first step exim accepts mail for addresses that are defined locally,
but then it delivers them to another host when it recognizes, that it isn't
the primary mx.

So why aren't we simply putting the external-router after the local routers?

The problem is, that we have redirects/forwarders, not only local mailboxes.
And we have no control about which addresses and domains are created on the
server.
Example: A customer creates the address hostmaster@???. Another user
has created a forwarder from his address to user@???. As soon as the
address hostmaster@??? has been created on our server, hotmail.com
would be treated as locally and thus the forwarders to the actual hotmail.com
wouldn't work.

So to prevent users from spoofing domains, we have the external router, that
forwards emails to the right mx.

But in the case above, this would end up in a loop, because mx 1 would accept
the mail, check it for spam, then forwards it to us, our mailserver accepts it
but then sees we are not the first mx, so it forwards it to the first. From
there on the loop repeats.

What is the solution?

>From what I can see the only solution would be to set a condition within the

external router so that it is only used if exim hasn't received the mail
directly from smtp, but it arised from a redirect. SO when a mail comes in, we
accept it and deliver it locally, no matter which other mx is defined. But if
there has been a forwarding from a local address to another address (e.g.
hotmail.com), then exim shall check if we are the primary mx for it. But how
can I do it?

Regards
Marten