Vps – Exim4: Receive and forward email for multiple domains

eximmail-forwardingubuntu-16.04vps

I'm running a VPS to host my client's websites. They have very limited email needs (basically they just want an info@clientdomain.com address that forwards to their gmail account). I have tried to set up exim4 (on ubuntu 16.04) to do this, but I just get 550 Unrouteable address.

Exim is currently sending mail fine. But my /etc/aliases file makes no difference:

postmaster:                     root
www-data:                       root
root:                           MYUSER@gmail.com
repairs@example-client1.co.uk:  example-client1@gmail.com
andrea@example-client2.com:     example-client2@gmail.com
me@MYDOMAIN.com:                MYSUER@gmail.com

I ran dpkg-reconfigure exim4 and told it the domains I want to accept:

dc_eximconfig_configtype='internet'
dc_other_hostnames='#######.com; ######.com; ####.com;#####.co.uk;'
dc_local_interfaces=''
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

I find exim's configuration confusing, and the documentation doesn't seem to help. I'd like to configure exim the "ubuntu way", so that future system updates don't break my setup.

I appreciate any help you can offer.

Best Answer

From your description, it appears you should be configuring your server as the primary MX for your clients' domains. There are a few addresses that likely should be delivered to you such as abuse, postmaster, webmaster and hostmaster. These should be handled by the default /etc/aliases file.

The default configuration only uses the local part to lookup aliases. You will need to handle your clients messages specially. As you are forwarding to Gmail, you may want to remail the message rather than forwarding it. This should deal with SPF and DMARC issues.

Where your are the secondary MX, the variable you need to set is dc_relay_domains. This should be a list of the domains you will be accepting email for as a secondary MX delimited by (':'). Whitespace is optional, but make the list easier to read.

The documentation for the file is available with the command man update-exim4.conf. You may also want become familiar with the Specification of the Exim Mail Transfer Agent document.

The command sudo dpkg-reconfigure exim4-config will provide a guided update of the /etc/exim4/update-exim4.conf.conf. However, you can edit the file by hand if you wish.

You may want to add the domains you are a secondary MX for to /etc/exim4/local_rcpt_callout. Please read the documentation to verify if this is appropriate. Bouncing mail for the domains you are secondary for after you have accepted the message is likely to generate back-scatter spam. This may get your server blacklisted.

The default configuration does not support domain names in the aliases file. I use the following to provide domain based aliases, although you likely should not have aliases for the domains you are a secondary MX for.

# This router handles aliasing using traditional /etc/aliases type files.
#
#### NB  You must ensure that /etc/exim/virutual/${domain} file exist
####
#### This works with the standard "name : destination" alias format

# Domain aliases
vdomain_aliases:
  debug_print = "R: vdomain_aliases for $local_part@$domain"
  driver = redirect
  allow_fail
  allow_defer
  domains = dsearch;/etc/exim4/virtual
  data = ${lookup{$local_part}lsearch*@{/etc/exim4/virtual/$domain}}
  qualify_preserve_domain
Related Topic