For those of us who weren't at class yesterday, virtual mail allows us to create a sort of forwarding table, that lets us map email addresses at a virtual domain to addresses elsewhere on the Internet. This allows us to do the following:
Say I have the domain `halo.net` (which I do), and I want to give all my friends email addresses @halo.net. I can't offer them accounts on the system, because I have too many friends and my computer isn't that big, but thats ok, because they already have too many accounts.
For our example, lets say I've got 5 friends who want to have @halo.net email addresses. Their email addresses are as follows:
Each of these users wants their email address to be:
I've written a simple system that allows virtual domain customers to
manage their own mappings. It preforms sanity checking on the configuration
files and allows users to be notified via email of configuration errors.
None yet. I'll fill in this section later.
Other Virtual Mail Resources
The package I've put together to manage and automate the use of virtual
mail domains has a few files that are responsible for automated processing
of configuration files, and others that contain the configuration and
data. Some files are generated automatically, others must be edited
or executed from the command line or from cron.
Files
This is a csh shell script that is usually run from cron. It runs
makemap and processes the output of /etc/makevirtual. I could probably
incorporate all of this functionality into /etc/makevirtual but this
way its a bit more moduler. Eventually some of the things that
happen in /etc/makevirtual should be moved here to allow /etc/makevirtual
to become a bit more generalized.
/etc/buildvirtual
This file is a perl script that is called by /etc/buildvirtual or run
from the command line. It processes the /etc/virtualdomains.conf
and parses and processes the individual configuration files. It performs
sanity checking on /etc/virtualdomains.conf and on the individual
configuration files. It will check for changes within the last
hour and send an email report of the processing of the individual
configuration file to the virtual domain owner. This allow correction
of errors. Any errors encountered in the processiong of the various
configuration files will result in that operation being aborted and the next
item being processed. Error messages will be printed in the /etc/virtualdomains
file and mailed to the user if the file was changed in the last hour.
/etc/makevirtual
Note that /etc/makevirtual contains site specific configuration
items that muct be changed in order for it to operate correctly.
This file contains the configuration for each virtual domain to be
sericed. Each line should have 3 space/tab delimited items on it;
domain, the default username, and the location of the user configuration
file. Invalid entries will be ignored. Comments using the '#' character
at the beginning of lines are honored.
/etc/virtualdomains.conf
This file is generated by /etc/buildvirtual. It contains the raw mappings
with comments and errors from /etc/makevirtual. It is used in the
process of making /etc/virtualdomains.db.
/etc/virtualdomains
This is the hashed database of mappings that sendmail uses for S98 re-writing.
It is created by /etc/buildvirtual from /etc/virtualdomains.
/etc/virtualdomains.db
These are the user configuration files that are specified in
/etc/virtualdomains.conf. Comments are honored, invalid entries are dropped.
The file contains mappings for the virtual domain in the form of:
username validemailaddress, where username is the name of some user@virtualdomain
and validemailaddress is a valid Internet email address.
~/username/domainname.email
In order to use this system, you have to install and configure a few
things.
Setup
Add:
Sendmail Configuration
LOCAL_CONFIG Kmaildomains hash /etc/virtualdomains.db LOCAL_RULE_0 R$+ < @ $+ . > $: $1 < @ $2 > . R$+ < @ $+ > $* $: $(maildomains $1@$2 $: $1 < @ $2 > $3 $) R$+ < @ $+ > $* $: $(maildomains $2 $: $1 < @ $2 > $3 $) R$+ < @ $+ > . $: $1 < @ $2 . >to your sendmail .mc file and regenerate it. OR Add:
Kmaildomains hash /etc/virtualdomains.dbbefore the 'Options' section in your sendmail.cf and add:
R$+ < @ $+ . > $: $1 < @ $2 > . R$+ < @ $+ > $* $: $(maildomains $1@$2 $: $1 < @ $2 > $3 $) R$+ < @ $+ > $* $: $(maildomains $2 $: $1 < @ $2 > $3 $) R$+ < @ $+ > . $: $1 < @ $2 . >to ruleset 98. Remember that you need to restart sendmail for the changes to take effect.
0 * * * * root /etc/buildvirtual
$this_host = "jurai.net"; $SENDMAIL = "/usr/sbin/sendmail"; $m_fullname = "Virtual Domains Subsystem Daemon"; $m_from = "virtual-domains\@intersurf.com";$this_host should have the value of whatever the email address for the virtualdomain users is. $SENDMAIL should be the path to your copy of sendmail (ver 8.7.x is what I'm using). $m_fullname is the full name of the account that the reports are emaild from. $m_from is the email address that is to send out the reports. I've added an entry to my aliases file that direccts email addressed to this account to the proper place (me!).
halo.net halo /h0/halo/halo.emailThis will enable virtual mail for the domain 'halo.net', using the default recipient user of 'halo' and will look for the config file as '/h0/halo/halo.email'.
halo.net IN MX 10 sasami.jurai.net. halo.net IN MX 20 dim.intersurf.net.This allows for email to be queued on dim if sasami is down. Sasami is the machine that my virtual domains in the example are hosted on.
The config file has only two elements per line. A username and a valid Internet email address. By valid I mean an email address that is delivered to a shell or POP email account.
Continuing the above example, I would add the following to /h0/halo/halo.email:
winter winter@jurai.net zakk zakk@intersurf.com qwerty coneill@oneill.net siva grendel@netaxs.com huaman abbyfg@tezcat.comThis would create the desired mappings as detailed above. When this file is processed, a default entry will be added using the values in /etc/virtualdomains.conf. This will map anything not matched to (in my case) 'halo@jurai.net'.
foo bla@halo.netin the above example.
foo halo@jurai.netisn't needed, since the mail will go there anyway.
`~!\@#\$%^&*()=\[\]{};'\:"|,\/\\?