Virtual domains with Exim 4 and Debian (updated)

Thu, 2009.01.15 - 17:16 — müzso

This tutorial describes pretty well how to configure a default Exim setup (in Debian) to support a number of domains for local delivery (ie. if your mail server serves multiple domains). However the article is a bit outdated (last mod. was in 2006), so here's a short update.

First reconfigure Exim via dpkg:

dpkg-reconfigure exim4-config

You can answer the config split question ("Split configuration into small files?") as you wish, but for "General type of mail configuration" select "Internet site", for "System mail name" specify whatever domain you seem fit (I entered the hostname of the server, as returned by the hostname --long command), for "IP-addresses to listen on for incoming SMTP connections" enter nothing or at least the public IP of the server, leave the "Other destinations" empty. Answer the remaining questions as you see fit.

Now edit the /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs file and replace the domainlist local_domains = MAIN_LOCAL_DOMAINS line with:

Create a a copy of the file /etc/exim4/conf.d/router/400_exim4-config_system_aliases and name it 410_exim4-config_virtual_aliases. In the copy replace the "system_aliases" string with "virtual_aliases", remove the line containing "domains = +local_domains", and replace the line starting with "data = ..." with this:

You can now create a file at /etc/exim4/domains.virtual containing one domain (FQDN) in a line, and a file at /etc/exim4/aliases.virtual containing an "alias: user" in every line (where alias should contain the domain too).
Eg.

mail@example.com: thomasinfo@example.org: david

where thomas and david should be local users on the server, and example.com and example.org should be listed in /etc/exim4/domains.virtual.

Finally: restart Exim

invoke-rc.d exim4 restart

You can test whether you where successful with the exim -d -bt mail@example.com 2>&1 | more command. It provides in-depth details on how Exim tries to handle a mail coming to the given address.

Eg. you could put an email-address into the target of an item in the aliases file.
Normally you put lines like this into aliases:

email_alias_name: account_name

This would deliver emails coming to the "email_alias_name@example.com" to mail repository of the local account with name "account_name".

But you can also have lines like this:

email_alias_name: forward@to.here.com

This will forward all mail coming to "email_alias_name@example.com" to "forward@to.here.com".

Another option would be (if you have no admin control of the mail server, but just being a simple user) to create a .forward file in the HOME directory of the user (who receives the emails) and put the email address into that file. All mail will be forwarded to that address (at least with the default Exim configuration ... of course a sys admin can change that and disable .forward support).