3

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.

Example:

*@domain-a.com > whatever@gmail.com

*@domain-b.com > mr_bob@hotmail.com

*@domain-c.com > fred@flintstone.com

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

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

I've created the directory /etc/exim4/fwd_domains and in that, the file domain-a.com:

# cat domain-a.com 
*: whatever@gmail.com

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 fred@domain-a.com
Subject: jdhfdjks
dsfhjdshf
.
Cc: 

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 ** fred@domain-a.com: 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?

Greg K
  • 169
  • 3
  • 12

5 Answers5

3

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

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

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.

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

This requires aliases like:

*@domain-a.com : whatever@gmail.com
*@domain-b.com : mr_bob@hotmail.com
*@domain-c.com : fred@flintstone.com
BillThor
  • 27,354
  • 3
  • 35
  • 69
1

Try a little more invasive debugging:

exim -bv -d+verify fred@domain-a.com
exim -bt -d+route fred@domain-a.com

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

0

Your director needs to be above the local delivery router.

topdog
  • 3,490
  • 16
  • 13
0

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 *@domain-a.com. 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.

coredump
  • 12,573
  • 2
  • 34
  • 53
0

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.

Jasper
  • 1,087
  • 10
  • 10