Setup exim to send unknown users’ mail through dnslookup/MX

emailexim

On a Debian Lenny server 'example.net', we have some cron jobs that need to send mail to 'job-owner@example.net'. The MX for the domain is an offsite dedicated SMTP server. Exim is using the system-aliases router to find the local user, and not finding him:

$ exim -bt job-owner@example.net
R: system_aliases for job-owner@example.net
job-owner@example.net is undeliverable: Unrouteable address

In /etc/aliases we have the normal redirect for system users to root, which I'd like to keep.

What is the best way to have exim send mail for users that aren't found locally to the SMTP host specified through dnslookup?

Best Answer

So, after your localuser router, add a slightly modified copy of your dnslookup router:

dnslookup2:
  driver = dnslookup
  domains = example.net
  transport = remote_smtp
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
  no_more

Note that "domains =" has been changed as has the name of the router.

FWIW it's an odd configuration to have the server in question think that example.net is local if it's being handled as a local domain, with a different set of valid users, somewhere else. Not a wrong configuration necessarily, but odd enough to make my "you may have made a wrong choice before you got here" sense tingle.