Make Exim deliver local mail externally

Solution 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) :

not_local:
  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 [64.18.6.10]