Is it possible to configure a Linux mail server (we're running exim) to forward unhandled emails to another server? Here's an example of what I'm trying to accomplish:

  • an email get's send to user@domain.com
  • the MX record for domain.com points to server1 so the email goes to server1
  • if server1 doesn't have an email forward or mailbox for user@domain.com it forwards the email to server2 that receives the email as if it was originally sent to it (as if the MX record pointed to server2 directly)

Is something like this possible? If it is, any information you can provide on how to accomplish this is highly appreciated.


  • What problem are you trying to solve, there may be a better way to do it. – DanBig Jul 23 '13 at 16:24
  • With postfix it could be done with luser_relay = $user@another.mx.example.net . I think exim have a similar solution – ALex_hha Jul 23 '13 at 16:33
  • 1
    You're looking to implement a shared SMTP namespace. I can't tell you how to do that with anything other than Exchange Server, but if you Google that term you should get plenty of results. – joeqwerty Jul 23 '13 at 17:38

It could be done with a router placed after all the routers that match local users.

An alternative would be to put a callout router early in the list that calls out to the second server and accepts mail if the user exist there. This would be my preference.

Routing would be:

  • Route to second server if address exists there.
  • Route locally for local addresses.
  • Reject.

EDIT Something like this should forward all unhandled mail for local domains to notlocal.host.ref.example. Mail for root is not forwarded. This router has not been verified, and does not handle address validation. You may need to remove the cannot_route_messages from a prior router.

   driver = manualroute
   transport = remote_smtp
   domains = +local_domains
   route_list = +local_domains  notlocal.host.ref.example
   local_parts = ! root
   cannot_route_message = Unknown user

Basically this is the final delivery router with the transport changed and check_local_user removed. Test before using.

  • Thanks. could you suggest which exim router could do this (and possibly how to configure it)? I'm especially interested in the first suggestion (place the router after all the local users are matched) since it would work best for this unusual setup we're creating. – Harry Muscle Jul 24 '13 at 4:16
  • @HarryMuscle I believe the manualroute router will do what you want. I've added an unverified example. – BillThor Jul 24 '13 at 5:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.