Configuring E-Mail Accounts for Virtual Subhosts

Virtual Subhosting is a powerful feature of our Virtual Server System. Using Virtual Subhosting, 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 ~/www/vthosts folder.

For example, if you had a domain name "my-virtual-server.com" which is mapped to an IP address of 192.41.5.172. All Virtual Subosted domain names on that Virtual Server (e.g. "a-virtual-subhost.com") will also have an IP address of 192.41.5.172. An HTTP/1.1 compliant server (such as that implemented in our Virtual Server System) 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@my-virtual-server.com" and "john@a-virtual-subhost.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.41.5.2" and "john@192.41.5.2". They are the same. So, from a virtual e-mail service perspective, it isn't the domain name that differentiates a user (the part after the @), it is the username/passwd sequence (the part before the @).

You are well aware of how to add a new FTP/POP account to your Virtual Server. You simply run the "vadduser" program from a command prompt or use the iManager web based "vadduser" wizard. Now, how can we resolve the dilemma of needing two usernames that are the "same"? We have developed a unique technology called "virtmaps". This is a proprietary feature of "sendmail", the underlying program which handles mail on your Virtual Server, only available on our Virtual Server System.

The "virtmap" feature will basically allow each domain to share common email user names. For example, if xyz.com and abc.com are subhosted 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 "ruser@isp.com" (a remote mail account on an access ISP's server). The feature also supports a "wild card" mapping in which mail to any user name for a domain name can be mapped to an 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 subhosted domain.

To take advantage of the virtmap feature you must update your sendmail.cf file and edit your "~/etc/virtmaps" file:

  1. 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 is used first.

    For example, assume I have the domains xyz.com and 123.com subhosted 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 subhosted on my Virtual Server and his user name is "biff". The owner of 123.com prefers to read his mail from his local ISP and his email address there is "bud@isp.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 subhosted on my Virtual Server. The user name for his secretary is "sue". To implement this I would add the following to my ~/etc/virtmaps using my favorite UNIX editor:

        webmaster@xyz.com   biff
        webmaster@123.com   bud@isp.com
        xyz.com             sue
        
  2. After you edit the "~/etc/virtmaps", run "vnewvirtmaps" from the command prompt:
        % vnewvirtmaps
        

    Note: The "vnewvirtmaps" command will update the "~/etc/virtmaps.db" database file.