In the system alias file, usually /etc/aliases, are the aliases of the servers own domain to be put. The server domain can be declared by the primary_hostname in Exim's configuration file used to be /etc/exim/exim.conf. But this isn't necessary since Exim will find out by it self otherwise. The alias file looks like this:
bashful: hiej@foo.se
doc: hiaj
The alias is on the left side of the colon character and on the right side is the user or the addressen where emails are to be redirected to. So if the server domain is localserver.se, all emails sent to bashful@lokalserver.se are going to be redirected to hiej@foo.se and emails to doc@localserver.se will be sent to the local user hiaj while there is no domain name on the right side of hiaj.
Virtual domains
All other domains can be put into a file called /etc/exim/domains.virtual:
hej.se
haj.se
hoj.se
Empty rows and rows starting with a # are ignored by the program. Exim needs this file in order to know what domains it is going to host, while per default rejecting email realy for other domains than its own.
The aliases of the virtual domains can be put in a file named /etc/exim/alias.virtual:
@hej.se: dopey
bashful@hej.se: grumpy
happy@hej.se: sleepy
info@hej.se: doc
@haj.se: raisins
bashful@haj.se: bread
happy@haj.se: milk
happy@hoj.se: cheese
snowwhite@hoj.se: dopey@externaldomain.se
info@hoj.se: coconut
This file looks almost the same as /etc/aliases. For each domain you can put a reciever for all emails to an alias not in the list. For example are emails to info@haj.se going to be redirected to the local user raisins. If someone sends an email to some non-existant addressee at hoj.se, Exim will send an error message back to sender.
Just as in /etc/aliases there can be put external addresses on the right side of the colon character. Thus all emails to snowwhite@hoj.se will be forwarded to dopey@externaldomain.se.
For Exim to recognize the virtual domains you have to put a search string into /etc/exim.conf:
domainlist local_domains = @:localhost:lsearch;/etc/exim/domains.virtual
Even here different values are seperated by colon. The @ character represent the local domain. lsearch does a linear search in /etc/exim/domains.virtual and looks for a domain name on each row.
The routers that redirect the emails should be somewhere below begin routers, preferably after system_aliases.
domains_virtual:
driver = redirect
data = ${lookup{$local_part@$domain}lsearch{/etc/exim/aliases.virtual}}
domains_virtual_others:
driver = redirect
data = ${lookup{@$domain}lsearch{/etc/exim/aliases.virtual}}
The first router handles emails directed to already existing aliases, while domains_virtual_others sends the rest of the mail to the user at the top of each domain. If you don't want this function for any of the domains the router can be deleted.
Debian GNU/Linux
To be able to make small changes to Exim's configuration file and at the same time be able to make use of Debian's configuration tool Debconf as good as possible the developers have chosen to to split the configuration file and then let the script update-exim4.conf output an "exim.conf".
Depending on the existing files update-exim4.conf reads the content of /etc/exim4/exim.conf.template or the files under /etc/exim4/conf.d each and /etc/exim4//etc/exim4/update-exim4.conf.conf in order to generate the file /var/lib/exim4/config.autogenerated that is used by Exim.
If /etc/exim4/exim.conf.template is used you can put the routers in the file and in /etc/exim4/etc/exim4/update-exim4.conf.conf change the value of the variable dc_other_hostnames to @:localhost:lsearch;/etc/exim/domaner.virtual exactly as above.
If instead the files under /etc/exim4/conf.d are used the /etc/exim4/etc/exim4/update-exim4.conf.conf has to be changed the same way as above. You can create a file called /etc/exim4/conf.d/router/410_exim4-config_virtual_domains for the routers so they will appear after system_aliases.
After these respective changes are made you can run the /usr/sbin/update-exim4.conf and then restart the Exim daemon with /etc/init.d/exim4 reload if the program is running as a daemon.
---
Aron Håkanson, aron@hakanson.se, 2004-04-19
Last changed: 2006-04-28