This howto is based on another article I've found online:
This howto contains steps for both exim 3 and exim 4 1).
Another article describes the steps to get exim + teapop installed for a basic mail server on your FREESCO.
The first step is to change your exim configuration. (For FREESCO 027 this file is /mnt/router/packages/exim/configure, for 03x this is /usr/local/exim/configure). For obvious reasons, make a backup of your config file first!
Locate the line with local_domains and make it look like this:
qualify_domain = dingetje.homeip.net local_domains = localhost:dingetje.homeip.net:dbm;/mnt/router/packages/exim/domains.dbm
your line may look different because you've already added other local domains or you've used a different local domain name. The important part is the last section where we tell exim to look into a database file. In this example I've located this file (on my FREESCO 027) in /mnt/router/packages/exim/domains.dbm. I suggest you use /pkg/etc/domains.dbm for FREESCO 03x.
Now scroll down to the DIRECTORS CONFIGURATION in your exim configuration and add this section as the first handler:
#
# for virtual domains
#
virtual:
driver = aliasfile
domains = dbm;/mnt/router/packages/exim/domains.dbm
no_more
file = /mnt/router/packages/exim/virtmail/${domain}
search_type = lsearch
Again these path names are for FREESCO 027, so make sure to change them for FREESCO 03x!
The most important part in this code is the line that says file =, notice the ${domain} code, this will get replaced with the virtual domain name later. The domains line must point to the domains database file that is created in the next step.
Save your changed configuration, but don't restart exim just yet!
First you need to change your exim configuration. (For FREESCO 027 this file is /mnt/router/packages/exim/etc/exim.conf, for 03x this is /etc/exim.conf). For obvious reasons, make a backup of your config file first!
Locate the line with domainlist local_domains and change it to look like this:
domainlist local_domains = localhost : your.domain.org : router.inet : dbm;/etc/mail/domains.dbm
your line may look different because you've already added other local domains or you've used a different local domain name. The important part is the last section where we tell exim to look into a database file.
Now scroll down to the ROUTERS CONFIGURATION in your exim configuration and add this section as the first handler:
#
# for virtual domains
#
virtual:
driver = redirect
domains = dbm;/etc/mail/domains.dbm
data = ${expand:${lookup{$local_part}lsearch*@{/etc/mail/virtmail/$domain}}}
no_more
These path names are for FREESCO 03x. You need to change them for FREESCO 0.2.7.
The most important part in this code is the line that says data =, notice the $domain code, this will get replaced with the virtual domain name later. The domains line must point to the domains database file that is created in the next step.
Save your changed configuration, but don't restart exim just yet!
Start by creating a text file called domains.list that contains all your virtual domains listed on a single line each, like so:
dingetje.homeip.net dingetje.hopto.org freescofaq.hopto.org
Next run the command exim_dbmbuild 2) to create the above mentioned domain database:
[Linux] exim_dbmbuild domains.list domains.dbm 3 entries written
If you get 'No such file or directory' or 'command not found' at this stage, then add the full path to the location of the exim_dbmbuild binary.
The next step is to create the virtual domain to local username mapping file(s). As you can see in the above code these files must be created in a directory /mnt/router/packages/exim/virtmail/ but of course you're free to change that to another location as long as you do it right!
Example : For FREESCO 03x I use the following : /etc/mail/virtmail
In a file dingetje.homeip.net I created these entries:
webmaster: webmaster@localhost postmaster: postmaster@localhost ikke: ikke@localhost
This tells exim to deliver mail for webmaster@dingetje.homeip.net to a local user webmaster (which must be a valid local mail account of course, see requirements, local user already delivery works).
Finally restart exim with:
rc_exim restart
We use exim from the commandline to test our new config (no actual mails are sent yet), as follows:
[Linux] exim -bv -d3 webmaster@dingetje.homeip.net Exim version 3.36 debug level 3 uid=0 gid=0 probably GDBM Caller is an admin user Caller is a trusted user virtual director: lsearch key=webmaster file="/mnt/router/packages/exim/virtmail/dingetje.homeip.net" virtual director generated webmaster@localhost errors_to=NULL transport=NULL uid=unset gid=unset home=NULL virtual director succeeded for webmaster system_aliases director: lsearch key=webmaster file="/etc/aliases" system_aliases director declined for webmaster: queued for local_delivery transport: local_part=webmaster domain=localhost errors_to=NULL domain_data=NULL local_part_data=NULL localuser director succeeded for webmaster webmaster@localhost <-- webmaster@dingetje.homeip.net deliver to webmaster in domain localhost director = localuser, transport = local_delivery webmaster@dingetje.homeip.net verified ok as webmaster@dingetje.homeip.net [Linux]
[Linux] exim -bv -d+verify webmaster@freesco.zapto.org webmaster@localhost <-- webmaster@freesco.zapto.org router = localuser, transport = local_delivery [...] routed by localuser router envelope to: webmaster@localhost transport: local_delivery search_tidyup called [Linux]
As you can see the webmaster account for the virtual domain is correctly verified and delivered to local user webmaster. This is exactly what we wanted. Now let's see what happens when a non-existing mail account is tried:
[Linux] exim -bv -d3 doesnotexist@dingetje.homeip.net Exim version 3.36 debug level 3 uid=0 gid=0 probably GDBM Caller is an admin user Caller is a trusted user virtual director: lsearch key=doesnotexist file="/pkg/exim/virtmail/dingetje.homeip.net" virtual director declined for doesnotexist: doesnotexist@dingetje.homeip.net failed to verify: unknown local-part "doesnotexist" in domain "dingetje.homeip.net" [Linux]
[Linux] exim -bv -d+verify doesnotexist@freesco.zapto.org Exim version 4.50 uid=0 gid=0 pid=1487 D=fbb95cfd [...] parse_forward_list: virtual router declined for doesnotexist@freesco.zapto.org "more" is false: skipping remaining routers no more routers doesnotexist@freesco.zapto.org failed to verify: Unrouteable address search_tidyup called [Linux]
Excellent!
Now create a similar file for the next virtual domain, dingetje.hopto.org, here I ommit the user ikke from the list:
webmaster: webmaster@localhost postmaster: postmaster@localhost
This means mails for webmaster for both dingetje.homeip.net and my other domain dingetje.hopto.org are delivered to the same local user webmaster, which is OK, because I can still tell in my mail client for which webmaster the mail originally was addressed to. However, there is no user ikke, so let's see what happens when I try this:
[Linux] exim -bv -d3 ikke@dingetje.hopto.org Exim version 3.36 debug level 3 uid=0 gid=0 probably GDBM Caller is an admin user Caller is a trusted user virtual director: lsearch key=ikke file="/pkg/exim/virtmail/dingetje.hopto.org" virtual director declined for ikke: ikke@dingetje.hopto.org failed to verify: unknown local-part "ikke" in domain "dingetje.hopto.org" [Linux]
[Linux] exim -bv -d+verify phbc50@rendezvous.dyndns.org virtual router declined for phbc50@rendezvous.dyndns.org "more" is false: skipping remaining routers no more routers phbc50@rendezvous.dyndns.org failed to verify: Unrouteable address search_tidyup called [Linux]
Perfect! This means I can send mails to ikke@dingetje.homeip.net, but since that user isn't included in the dingetje.hopto.org, it will bounce.
A .forward file can be used to make sure a mail message is delivered further from a local user account to any other valid mail address on the planet.
To make this work, verify the next code is in place in the exim configuration:
userforward: driver = forwardfile file = .forward no_verify no_expn check_ancestor # filter file_transport = address_file pipe_transport = address_pipe reply_transport = address_reply
userforward: driver = redirect check_local_user file = $home/.forward no_verify no_expn check_ancestor # allow_filter file_transport = address_file pipe_transport = address_pipe reply_transport = address_reply
Next generate a .forward file (don't forget the dot, very important) in the $HOME directory of the local user (check your /etc/passwd file if you don't know the login directory for a certain local user), and make it look like this:
\local_user, some.one@no.where, some.dude@does.not.exist
So basically supply all mail addresses that should receive the message. The first argument with the backslash assures the message is also delivered to the local user local_user 3).
very important: make sure the .forward file is owner and readable only by this local_user, so:
chown local_user.user .forward chmod 600 .forward
— dingetje 2005/06/28 00:09