0

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.

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
| improve this answer | |
  • 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? – James Swift Sep 17 '16 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 '16 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? – James Swift Sep 18 '16 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 '16 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 me@example.com to myemail@gmail.com
me: myemail@gmail.com

# This will forward postmaster@example.com to dave@gmail.com
postmaster: dave@gmail.com

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

| improve this answer | |
  • 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 – BringBackCommodore64 Aug 22 '17 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 – BringBackCommodore64 Aug 22 '17 at 16:56
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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