0

I'm running a VPS to host my client's websites. They have very limited email needs (basically they just want an [email protected] 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:                           [email protected]
[email protected]:  [email protected]
[email protected]:     [email protected]
[email protected]:                [email protected]

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.

4 Answers 4

2

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
4
  • Thank you, I will try that. Will that only forward emails as define in /etc/aliases? Should I also have that list of domains in the dc_other_hostnames variable too? Or is that for a different purpose? Sep 17, 2016 at 21:16
  • @JamesSwift dc_other_hostnames has a different purpose. It covers other names your host is known as. It may be appropriate to set it to values like mail.example.com, gandalf.example.com if your domain is example.com, its hostname is gandalf and it is your mail.example.com mail server. You could also set it to *.example.com. I've also edited my answer.
    – BillThor
    Sep 17, 2016 at 21:53
  • thanks for your continued help. How can I embed the vdomain_aliases setup you mentioned without it being overridden by future updates? Sep 18, 2016 at 18:18
  • @JamesSwift The easiest way is to use the split configurations. Add the router as a file in the /etc/exim4/conf.d/router directory. I used the file name 380_local-config_vdomain_aliases to sequence it between the real_local and system_aliases routers.
    – BillThor
    Sep 19, 2016 at 3:46
2

This is a summary of @BillThor's answer, with some added detail:

Step 1

Edit /etc/exim4/update-exim4.conf and set dc_other_hostnames to include all the domains you will be forwarding mail for. (If you forget to do this, messages will be bounced).

Step 2

Create a directory /etc/exim4/virtual and add one file per domain, named exactly the domain name. Fill the files with the aliases you wish to forward. For example

# File: /etc/exim4/virtual/example.com

# This will forward [email protected] to [email protected]
me: [email protected]

# This will forward [email protected] to [email protected]
postmaster: [email protected]

Step 3

Create a new file /etc/exim4/conf.d/router/350_local-config_vdomain_aliases, with the content:

# 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

Step 4

Run:

update-exim4.conf
service exim4 restart

Thanks for all your help @BillThor

3
  • Could you please share your configurations of /etc/exim4/update-exim4.conf? Also, how did you manage to send email from Gmail using the above instructions? Thanks Aug 22, 2017 at 16:45
  • I forgot to ask: what about /etc/exim4/exim4.conf.template? How does it looks like? What changes you made to it? Thanks Aug 22, 2017 at 16:56
  • 1
    This now fails with a 'tainted filename' error. Aug 22, 2021 at 8:50
1

There is nothing wrong with the other answers, but I would like to refer to the official exim specification (=documentation):

https://www.exim.org/exim-html-current/doc/html/spec_html/ch-some_common_configuration_settings.html#SECTvirtualdomains

There is a high chance this will be up-to-date and maintained documentation for years to come.

0

If you are running exim as daemon (as it is in the default setup of the Debian packages) you should not invoke update-exim4.conf directly when exim is running. For SMTP receiving or queue running, exim forks, and the new processes would use the new configuration file, while the original main exim daemon would still use the old configuration file. You should use invoke-rc.d exim4 restart instead.

Source: https://manpages.debian.org/jessie/exim4-config/update-exim4.conf.8.en.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .