I have setuped an Exim4 server on my debian wheezy server. This mail server only sends mail coming from localhost. The purpose is sending mail for my website.

I have cron tasks and other services generating mails for root user. These mails are not stored in /var/mail as before, but sent by exim to root@mydomain.com.

I try to make exim send mails for root to mypersoaddress@gmail.com rather than root@mydomain.com.

I tried adding a .forward in /root with mypersoaddress@gmail.com as content. I tried also changing /etc/aliases with root: mypersoaddress@gmail.com. The fact is that routing works for root@localhost but not for root which is resolved as root@mydomain.com

I tested how routing is resolved with exim -bt :

root@srv02:~# exim -bt root@localhost
R: system_aliases for root@localhost
R: dnslookup for mypersoaddress@gmail.com
mypersoaddress@gmail.com
    <-- root@localhost
  router = dnslookup, transport = remote_smtp
  host gmail-smtp-in.l.google.com      [173.194.67.27] MX=5
  host alt1.gmail-smtp-in.l.google.com [74.125.143.27] MX=10
  host alt2.gmail-smtp-in.l.google.com [74.125.25.27]  MX=20
  host alt3.gmail-smtp-in.l.google.com [173.194.64.27] MX=30
  host alt4.gmail-smtp-in.l.google.com [74.125.142.27] MX=40
root@srv02:~# exim -bt root
R: dnslookup for root@mydomain.com
root@mydomain.com
  router = dnslookup, transport = remote_smtp
  host aspmx.l.google.com      [173.194.78.27] MX=1
  host alt1.aspmx.l.google.com [74.125.143.27] MX=5
  host alt2.aspmx.l.google.com [74.125.25.27]  MX=5
  host alt4.aspmx.l.google.com [74.125.142.27] MX=10
  host alt3.aspmx.l.google.com [173.194.64.27] MX=10

I bet this is a matter of how my server is configured (rather than how exim is configured). But to understand well I would like to have a solution for both :

  • how to have root resolved as root@localhost ?
  • how to have root@mydomain.com routed to mypersoaddress@gmail.com ?
up vote 3 down vote accepted

The debug output you are using indicates you're using a Debian style configuration system. I'm going to refer to this as exim4 in order to make it clear that there is some extra configuration magic occurring beyond the default exim config that comes in the source. Anybody reading this later needs to clearly understand that some of this suggestion does not apply unless they are running Debian style exim configs.

The difference in your -bt output gives a clue:

root@srv02:~# exim -bt root@localhost
R: system_aliases for root@localhost
R: dnslookup for mypersoaddress@gmail.com
mypersoaddress@gmail.com

root@srv02:~# exim -bt root
R: dnslookup for root@mydomain.com
root@mydomain.com

In the first one, it knew to look in the system_aliases router because "localhost" is configured to be one of the domains that is allowed to look in the aliases file. But in the second one, it skipped over that aliases file because "mydomain.com" is not in that list. In exim4, that list is the MAIN_LOCAL_DOMAINS macro.

By my estimation, one of these things is probably going to solve your problem. Items 2 and beyond are potential adjustments to your exim.conf. Since you run exim.4, you need to be adjusting Debian mail configuration files in /etc/exim/ and then run exim4-conf.conf or something like that to have those changes read in and generate the new configuration file (/var/lib/exim4/config.autogenerated*) that exim4 actually uses.:

  1. Make sure that the /root/.forward file is readable by the exim user.
  2. Add mydomain.com to the list of domains called +local_domains which should then make exim4 look for the $HOME/.forward file. It does sound like you already have this set correctly.
  3. Move the userforward router to occur before the dnslookup router (which it already does, but maybe you have changed the default router layout?)
  4. Add mydomain.com to the list of domains allowed to search the aliases file. (likely this will break other things)
  • Thanks Todd for these hints. All this has a lot of sense, but practicaly I am a bit lost with exim config. Can you add information regarding where are defined "+local_domains" and routers order ? – iwalktheline May 26 '14 at 14:57
  • 1
    Added some additional clarification. – Todd Lyons May 30 '14 at 15:21

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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