[svlug] Help with virtualhosts and aliases

Mark Symonds mark at symonds.net
Thu Jun 15 01:24:45 PDT 2006


On Wednesday 14 June 2006 19:52, Jeremy Brown wrote:
> Daevid Vincent wrote:
> > mail-mta/exim 4.54
>
> Not sure if it's do-able in Exim.  I've really only used Sendmail with
> any frequency.  Maybe someone else can chime in, or you might post to
> Exim mailing lists.
> 

No idea how to do it under debians hoarked up hairball of a split configfile 
scheme for exim, but with a monolithic configfile it isn't too hard: 

* Create a plain text flat file e.g. "/etc/exim4/vdomains" containing a list 
of the domains you service, one per line: 

marq.org
anotherdomain.com
yaythisisntsohard.net 

* In your exim4.conf, tell exim to lsearch ("linear search") that file when 
processing the local_domains parameter, e.g. 

domainlist local_domains = "localhost:primary.com:lsearch;/etc/exim4/vdomains"

* Add a router like this to your routers section, preferably 
right above the router which handles your /etc/aliases: 

virtual:
  driver = redirect
  domains = lsearch;/etc/exim4/vdomains
  data = ${lookup{$local_part}lsearch*{/etc/exim/virtual/$domain}}
  user = Debian-exim
  group = Debian-exim 
  file_transport = address_file
  pipe_transport = address_pipe
  no_more 

Commands to get this router working: 

mkdir /etc/exim4/virtual
touch /etc/exim4/virtual/marq.org

The "data" parameter up there tells exim to look in /etc/exim4/virtual for 
aliasfiles which are named after your "virtual" domains. 

Now exim should use the file /etc/exim4/marq.org as the aliasfile for email 
delivered to marq.org.  /etc/exim4/marq.org follows the standard aliasfile 
format e.g. 

info: someone at gmail.com
marq: fhp at localhost
webmaster: webdevel at somewhere, marq at localhost, anotherone at gmail.com

...and so on.  Once this initial setup is complete you can simply append new 
domains to /etc/exim/vdomains and "touch /etc/exim/virtual/newdomain.com"
to get it working.  

You can add a wildcard to the top of your virtual aliasfiles like this: 

*: fhp at localhost

Note that the wildcard is a bit different here - it means "Deliver to this 
*only if none of the others match*".  Per above examples, info at marq.org would 
still go to someone at gmail.com but something like sadlghfsa21i34 at marq.org 
would hit the wildcard and deliver to fhp at localhost. 

Also here: 

http://www.exim.org/exim-html-4.62/doc/html/spec_html/ch46.html#SECTvirtualdomains

Good luck, and have fun. 

Mark 





More information about the svlug mailing list