Virtual E-Mail Mapping using virtmaps
Virtual hosting is a powerful feature of the Virtual Server. Using
virtual hosting, you can map several domain names to the same Virtual
Server (and the same IP address) and configure the web server to have each
domain name pointed to content in separate subdirectories in your htdocs
folder.
For example, if you had a domain name "example.com" which is
mapped to an IP address of 192.168.1.1. All Virtual Hosted domain names on
that virtual server (e.g. "example-vhost.com") will also have an
IP address of 192.168.1.1. An HTTP/1.1 compliant server (such as that
implemented in our Virtual Servers) can detect the difference between the
domain names when an HTTP request is made and appropriate content is sent
back to the client. However, your e-mail services (without modification)
cannot
detect the difference.
To the e-mail server, both "john@example.com" and
"john@example-vhost.com" are the same john. This is because the
domain names both resolve to the same IP address. In other words, the
e-mail server sees both addresses as "john@192.168.1.1" and
"john@192.168.1.1". They are the same. So, from a virtual e-mail
service perspective, it isn't the domain name that differentiates a e-mail
user (the part after the @), instead it is the username (the part before
the @) that does.
You are probably well aware of how to add a new FTP/POP account to your
Virtual Server. You simply run the "vadduser" program from a
telnet shell prompt. Now, how can we resolve the dilemma of needing two
usernames that are the same? Virtual e-mail mapping is a relatively new
technology that has been implemented as feature of sendmail, the
underlying program which handles mail on your Virtual Server.
The virtual e-mail mapping (or virtmap for short) feature will
basically allow each domain to share common email user names. For example,
if xyz.com and abc.com are hosted on the same virtual server, both domains
can have mail to
"webmaster" go to separate mail boxes. Mail to
"webmaster@xyz.com", for example, can be mapped or routed to
"user1" (a local pop account) and mail to
"webmaster@abc.com" could be routed to "auser@isp.com"
(a
remote mail account on an dial up ISP's server). The feature also supports
"wild card" mapping in which mail to any user name for a domain
name can be mapped to a single user. This can used as a "catch
all" or in conjunction with other mappings to route "User
Unknown" mail to an
autoreply or an account acting as a postmaster for the virtual hosted
domain.
To take advantage of virtual e-mail mapping, you need to edit your
"~/etc/virtmaps" file:
-
Edit ~/etc/virtmaps and add email address mappings. The left hand side
is the email address that mail is *sent* to and the right hand side is the
email address mail is *delivered* to. If the left hand side just contains
a domain name then all mail to that domain name will be delivered to the
email address on the right hand side. In other words, you can have either
"email address -> email address" or "domain name -> email
address" mappings in this file. It is a good idea to put all
"domain name -> email address" mappings at the bottom of the
file so that it tries the "email address -> email address"
mappings first. Note that the first mapping that matches will be used.
For example, assume I have the domains xyz.com and 123.com virtually
hosted on my virtual server. Both owners of these domains want mail to
"webmaster" for their domain name to come to them. The owner of
xyz.com has a mail box hosted on my virtual server and his user name is
"joe". The owner of 123.com prefers to read his mail from his
local ISP and his email address there is "tom@mindtrap.net".
Also, the owner of xyz.com would like mail not address to
"webmaster@xyz.com" (any other username but
"webmaster" sent to this domain) sent to his secretary who also
has a mail box hosted on my virtual server. The user name for his
secretary is "sam". To implement this I would add the following
to my ~/etc/virtmaps using my favorite UNIX editor:
| webmaster@xyz.com | joe |
| xyz.com | sam |
| webmaster@123.com | tom@mindtrap.net |
-
After you edit "~/etc/virtmaps", run "vnewvirtmaps"
from the command prompt:
% vnewvirtmaps
Note: The "vnewvirtmaps" command will update the
"~/etc/virtmaps.db" database file.
|