How To: Exim4 Virtual Host on Debian Etch
Well, since I reinstalled a Debian, I decided to make an article on Exim4, as a complement to Postfix and Virtual Host.
Exim4 is the default MTA (Mail Transport Agent) shipped with Debian. It offers really ecellent macros which help a lot in configuring a wide system by automatizing task the administrator would have to do otherwise, but in the other hand, it is not as easy as postfix to configure on a first glance.
Well, as usual, you need to install the require package before starting up.
# apt-get install exim4
By now, you should have gone through a few question the installer ask you. If not, you might want to re-run the config settings:
# dpkg-reconfigure exim4-config
You need to answer “No” to the first question (do not split in small files), otherwise this how-to won’t work.
Smarthost is simply your internet access provider’s smtp host.
Now that everything is under hand, let’s move to /etc/exim4.
Here is the scenario: I’m going to set up a virtual mail server for host mailhost.net and mailhost.org, I want the first one to be redirected to mailhost2.net and the second one to mailhost2.org.
In the first place, we need to create one separate file for each host, and important, it must have the same name as the virtual host.
# cd /etc/exim4
# mkdir virtualhosts
# touch virtualhosts/mailhost.net virtualhosts/mailhost.org
Now, edit each of those file with the value you like, for instance for mailhost.net:
user: [email protected]
*: [email protected]
Now, go to the main configuration file: /etc/exim4/exim4.conf.template and edit it by setting the line containing “domainlist local_domains” to:
domainlist local_domains = @:localhost:dsearch;/etc/exim4/virtualhosts
Now, search for “begin routers” and add between:
#####################################################
### end router/300_exim4-config_real_local
#####################################################
and
#####################################################
### router/400_exim4-config_system_aliases
#####################################################
add the following block:
#####################################################
### router/350_exim4-config_vdom_aliases
#####################################################
vdom_aliases:
driver = redirect
allow_defer
allow_fail
domains = dsearch;/etc/exim4/virtualhosts
data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtualhosts/$domain}}}
retry\_use\_local_part
pipe\_transport = address\_pipe
file\_transport = address\_file
no_more
#####################################################
### end router/350_exim4-config_vdom_aliases
#####################################################
And here you are. Restart exim:
/etc/init.d/exim4 restart
And it should run smmothly :p.