Current situation:
We have a VPS that hosts a website example.org. Exim is configured to work as a smarthost. All emails sent through exim are successfully relayed to another mail server (that is working on example.com).

To forward mail sent to *@example.org to *@example.com, i.e. change the recipient's address from *@example.org to *@example.com.

If I send email to address *@example.org, then it seems exim doesn't change the address, it still relays the message to another mail server but recipient is still *@example.org. Maybe the redirect is not applied for some reason.

Configuration and logs:



/etc/exim4/conf.d/router/999_exim4-config_redirect (created by me):

     debug_print = "R: forward for $local_part@$domain"  
     driver = redirect  
     domains = example.org
     data = it@example.com

(for now data is set to a specific address for simplicity and testing)

exim log when sending email to it@example.org (should be redirected to it@example.com):

2012-03-20 19:40:07 1SA4ud-0005Dw-7k <= test@example.org U=www-data P=local S=657
2012-03-20 19:40:08 1SA4ud-0005Dw-7k => it@example.org R=smarthost T=remote_smtp_smarthost H=domain2.com [] X=TLS1.0:RSA_AES_256_CBC_SHA1:32 DN="C=US,,ST=TX,L=Houston,STREET=Suite 400,STREET=11251 Northwest Freeway,O=HostGator.com,OU=HostGator.com,OU=Comodo PremiumSSL Wildcard,CN=*.hostgator.com"
2012-03-20 19:40:08 1SA4ud-0005Dw-7k Completed

So, the address is not changed :(

Please help! I'm trying to make it work for half a day already :(

So, aseq helped me to solve the problem. Although the solution looked a little bit weird to me. When I tried to set dc_use_split_config='true' it didn't help, it looked like my redirect file was not used. Also when I tried to add those redirect lines to the end of /etc/exim4/exim4.conf.template it didn't help either. But when I tried to paste those lines after "begin routers" line it finally worked!

1 Answer 1


Please use example.com instead of domain2.com, example.com (and .org .net) was specifically created for examples and documentation.

In your /etc/exim4/update-exim4.conf.conf you have configured:


However you are changing something in /etc/exim4/conf.d/router/999_exim4-config_redirect which will be ignored because you are not using split configuration.

Either do:


And reload exim4, you may prefer to change it using:

dpkg-reconfigure exim4-config

Or edit /etc/exim4/exim4.conf.template to add your customisations instead and reload exim4 once done.

Debian exim4 has a feature called hubbed_hosts which can be a convenient way to accomplish what you want without having to add your own routers et al.

So if your want your server to send email destined for domain example.org to domain example.com which has MTAs listening on IPs and you do the following:

  • Create /etc/exim4/hubbed_hosts and add:


  • reload exim4

Note, no spaces between the IP addresses and they're separated by a colon ':'

What this does is it will relay email destined for example.org to IPs, (in my example the IPs of example.com). It therefore will ignore the MX records of that domain. The IP address could be anything, as long as it is configured to receive those emails.

Finally there is address rewriting, see: http://www.exim.org/exim-html-current/doc/html/spec_html/ch31.html Perhaps it has something that will fit your requirements. You could use it in addition to hubbed_hosts.

  • Thank you for your answer. But I have changed to dc_use_split_config='true', restarted exim4 and nothing changed. I also tried to add those redirect settings to /etc/exim4/exim4.conf.template and again, no luck :(
    – nightcoder
    Mar 20, 2012 at 21:21
  • See updated answer.
    – aseq
    Mar 20, 2012 at 21:34
  • aseq, I want my server to send email destined for xxx@example.org to xxx@example.com, I mean I want it to substitute the recipient address. If I simply send email with recipient xxx@example.org to a mail server on example.com then that mail server will not accept email because it will think it does not serve for example.org domain.
    – nightcoder
    Mar 20, 2012 at 22:36
  • You can configure the mail server on example.com to accept email for example.org. You would configure: dc_other_hostnames='example.org;example.net'
    – aseq
    Mar 20, 2012 at 23:30
  • Also check my updated answer for address rewriting.
    – aseq
    Mar 20, 2012 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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