Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

UPDATE: Thanks for responses on this but I'm going to drop exim and try Postfix.

My question is pretty similar to this one. I want to configure exim4 (on ubuntu 10.04) to forward/redirect all e-mail on a domain to an external address. My server hosts multiple domains. This is a pretty straight forward setup but I'm struggling to get it working.


* >

* >

* >

I tried adding the following to /etc/exim4/exim4.conf.template but the director isn't matching:

  driver = redirect
  domains = dsearch;/etc/exim4/fwd_domains
  data = ${lookup{$local_part}lsearch{/etc/exim4/fwd_domains/$domain}}

I've created the directory /etc/exim4/fwd_domains and in that, the file

# cat 

Update: I'm not convinced this syntax is correct. More importantly, my director doesn't seem to be picked up before reaching this point.

Run update-exim4.conf & restart exim4.

Send test e-mail:

# mail
Subject: jdhfdjks

This appears in /var/log/exim4/mainlog:

2010-07-07 22:21:51 1OWd03-0002Zv-Kx <= root@primarydomain U=root P=local S=332
2010-07-07 22:21:51 1OWd03-0002Zv-Kx ** Unrouteable address
2010-07-07 22:21:51 1OWd03-0002Zx-MB <= <> R=1OWd03-0002Zv-Kx U=Debian-exim P=local S=1111
2010-07-07 22:21:51 1OWd03-0002Zv-Kx Completed
2010-07-07 22:21:51 1OWd03-0002Zx-MB => /var/mail/mail <root@primarydomain> R=mail4root T=address_file
2010-07-07 22:21:51 1OWd03-0002Zx-MB Completed

My director doesn't fire and the e-mail ends up in root's mailbox. Any ideas?

share|improve this question

Use a wildcard search 'lsearch*' instead of 'lsearch'. This will match the wildcards.

  driver = redirect
  domains = dsearch;/etc/exim4/fwd_domains
  data = ${lookup{$local_part}lsearch*{/etc/exim4/fwd_domains/$domain}}

Alternatively you can put your aliases in /etc/aliases and use a router like this. You can change the domains option as appropriate for your configuration. The above dseach would be appropriate.

  driver = redirect
  domains = ! +local_domains : +relay_to_domains
  data = ${lookup{$local_part@domain}lsearch*{/etc/aliases}}

This requires aliases like:

* :
* :
* :
share|improve this answer

Try a little more invasive debugging:

exim -bv -d+verify
exim -bt -d+route

Your config looks sane (textbook even), more detail is needed on the failures.

share|improve this answer
verify: route: – Greg K Feb 28 '11 at 11:15

Your director needs to be above the local delivery router.

share|improve this answer
I've tried moving my director to the top of the routers section of exim4.conf.template but I still get the same problem - unrouteable address. – Greg K Jul 19 '10 at 12:00
check what happens with exim -bt address@domain – topdog Jul 19 '10 at 19:03
$ exim -bt is undeliverable: Unrouteable address – Greg K Jul 28 '10 at 21:46
do you have it listed in your relay_domains – topdog Jul 29 '10 at 6:30
I don't think so: – Greg K Jul 30 '10 at 21:30

At the Exim docs there's something about lsearch not expanding the wildcards, and using wildlsearch to expand the keys before searching. I think the way you are doing now would only match the address * Take a look at the examples in the docs. Also, as a catch-all email, the router should be probably after all other meaningful routers, or it will catch valid emails before they are delivered.

share|improve this answer
There's no local recipients at the domain, it's all forwarded to gmail accounts. – Greg K Aug 2 '10 at 9:42

This is probably so obvious you already checked, but you never know.

Are you use by any chance using the split configuration scheme?

In that case you should ignore exim4.conf.template and go with /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs instead.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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