3

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).

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

Problem:
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/update-exim4.conf.conf:

dc_eximconfig_configtype='smarthost'
dc_other_hostnames=''
dc_local_interfaces=''
dc_readhost='example.org'
dc_relay_domains='example.org'
dc_minimaldns='false'
dc_relay_nets='0.0.0.0/32'
dc_smarthost='example.com::26'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'

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

 domain_redirect:  
     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 [184.172.146.66] X=TLS1.0:RSA_AES_256_CBC_SHA1:32 DN="C=US,2.5.4.17=#13053737303932,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 :(

Solution:
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

3

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:

dc_use_split_config='false'

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:

dc_use_split_config='true'

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 192.0.2.1 and 192.0.2.10 you do the following:

  • Create /etc/exim4/hubbed_hosts and add:

    example.org: 192.0.2.1:192.0.2.10

  • 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 192.0.2.1,192.0.2.10 (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.

6
  • 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.