We've got an unusual mail setup - Google Apps/Gmail in front, with Exim running on our webserver. Mail for any account that doesn't exist in Google Apps is forwarded to Exim. Both of these use the same domain.

Problem is, all mail sent from the Exim accounts (or our PHP app) is only delivered locally, not sent through Gmail.

To perhaps illustrate it better, see this high-quality chart:

[Google Apps] (Tom, Dick, Harry)

[Exim] (Jane, Mary, Sue)

Mail sent to Jane gets forwarded to Exim by Google. Mail sent to Tom is simply delivered by Google. This is the part that works - the problem is, Jane can't email Tom because as far as Exim is concerned, it runs the whole show.

I'm reading about setting up a SmartHost in Exim, but that requires authentication - and critically, the accounts in Exim do not match those in Apps.

How can I configure Exim to deliver local mail via external routes?

  • I'm not really understanding the question. Are you asking how to configure SMTP namespace sharing so that emails delivered to domains that Exim is authoritative for get delivered to Google Apps instead?
    – joeqwerty
    Jan 8, 2014 at 22:24
  • The domain's MX entry points to Apps. I need mails sent to the domain from Exim are routed to Google instead of locally.
    – Sudowned
    Jan 8, 2014 at 22:32
  • So you're saying that externally the MX record points to Google Apps but internally Exim is authoritative for the domain and any emails sent from the Exim mailboxes doesn't get delivered externally? If so, then you need to set up SMTP namespace sharing.
    – joeqwerty
    Jan 8, 2014 at 22:34
  • @joeqwerty Google's surprisingly unhelpful - I did try the advice in this answer: serverfault.com/questions/525682/… but I couldn't get it to work.
    – Sudowned
    Jan 8, 2014 at 23:36

1 Answer 1


Based on the answer you referenced in the comments of the question (Configure server to foward unroutable emails to another email server), I rewrote the logic part to use the whole email address, not just the local part. The following seems to work in my testing.

1) Put example.com in your +local_domains.

2) Add the router he recommended. (There should be another router following this one that accepts +local_domains and users that do have valid local mailboxes) :

  driver = manualroute
  domains = +local_domains
  transport = remote_smtp
  condition = ${lookup{$local_part@$domain}lsearch{/etc/exim/forward_to_google}}
  # Use whatever MX is correct for your domain below
  route_list = +local_domains s7a1.psmtp.com

3) Create /etc/exim/forward_to_google and put in it:

[email protected]: yes
# Not required if this is a local account, but
# shows how flexible this approach can be
[email protected]: no

4) You can test with exim's -bt address test option (my config doesn't have that second router for the valid local users, but yours should so the first user would show a local delivery):

$ exim -bt [email protected]
[email protected] is undeliverable: Unrouteable address
$ exim -bt [email protected] 
[email protected]
  router = not_local, transport = remote_smtp
  host s7a1.psmtp.com [] 
  • 2
    This appears to work brilliantly. I'll accept the answer shortly, currently running some in-depth testing. Also, please accept my heartfelt thanks for answering a question for which the typical response is "Why would you do that? Stop trying."
    – Sudowned
    Jan 10, 2014 at 18:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .