| Last Updated: February 07, 2007 |
Incoming email messages can be sorted based on the recipient domain name with the virtusertable utility. Because user accounts are not directly associated with any specific domain names, a virtusertable must be used to differentiate between recipient domain names. For example, a virtusertable mapping will allow you to direct email messages for webmaster@mydomain.name and webmaster@subhost.name to different users on the VPS v2/v3.
Configuring Virtusertable mappings
In order to create virtusertable mappings, you must first create a text file in the /etc/mail/ directory of your server (there is a sample file in that directory named virtusertable.sample). The sample file contains virtusertable mapping examples.
Each entry in a virtusertable must be on a single line. The original recipient address on the left hand side, with one or more spaces or tabs separating it from the right hand side, which contains the destination address. Using the example above, the virtusertable mapping would be as follows:
webmaster@mydomain.name tom
webmaster@subhost.name steve
The original recipient is the email address that people will send messages to and can be either a full address (username@domain.name), or a catchall for all messages to the specified domain (@domain.name). If you want to create multiple virtusertable entries for a single domain, make sure that you put the catchall below any other entries for that same domain name. For example:
webmaster@mydomain.name tom
support@mydomain.name someuser@hotmail.com
john@mydomain.name john
@mydomain.name john
The destination address should be a local user, an alias, or a remote email address. You may also use a %1 to indicate that the original user should be prepended to a catchall.
Any time you make a change to the /etc/mail/virtusertable text file, you will need to create a database (.db) file that sendmail will read. The following command will create the /etc/mail/virtusertable.db file when run by root:
# makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable
Also the vnewvirtmaps command has been created for the VPS v2/v3 server as an additional command that is easier to remember. Both commands will accomplish the same task and create a new database file however the vnewvirtmaps command is only available on VPS servers. To use the vnewvirtmaps command to create a database file for your virtusertable, run the following command:
# vnewvirtmaps
Example Virtusertable Entries
The following entry would deliver any message sent to floyd@super-host.com to the local account floydr.
floyd@super-host.com floydr
The next entry will deliver a message sent to john@super-host.com to his email account with his ISP.
john@super-host.com jfranklin@my-isp.com
Any other email sent to the super-host.com domain will go to Floyd's local account.
@super-host.com floydr
Anything sent to a user at funsites.com will be sent to awesome-web.com, but will not change the username the message was originally sent to (only the domain is modified).
@funsites.com %1@awesome-web.com
|