Server Aliases and Virtual Hosts
When you configure your server’s DNS records, you might assign multiple domain names to the same server. The most common example is a web server in which you want to have myserver.org, myserver.com, and myserver.net to all point to the same server and website. The same approach can be taken with an email server; however, in addition to specifying this information in the DNS registration for the domain names, you must also tell the server which domain names it is allowed to accept email for. Otherwise, the server accepts only mail for the fully qualified domain name that was specified during server setup.
These alternate domain names that a server accepts mail for are known as local host aliases. To add support for these domain names, use the Hosting tab of the Advanced Mail Service Settings pane (as shown in Figure 3). The Local Host Aliases listbox lists the domain names that your mail server accepts mail for. To add a domain name to the list, click the Add button and enter the domain name. To remove of modify a domain name, select it in the list and click the Delete or Edit button. By default, only the fully qualified domain name specified during server setup is listed. Also, keep in mind that if your DNS records contain an MX entry to indicate that mail.myserver.com is the server handling email for the domain myserver.com, you should enter both names as local host aliases.
Figure 3 Hosting tab of the Advanced Mail Service Settings Pane
When using local host aliases, the username portion of the email address always determines the recipient, regardless of the domain name. For example, if I set up a mail server with local aliases for the domains myserver.com and myserver.edu and then create a mail-enabled user account for myself, email sent to firstname.lastname@example.org and email@example.com would be sent to the same mailbox. In some situations, however, you might want to use a single mail server to manage email for multiple domains—each with different sets of users. This requires configuring virtual hosting for the server.
When operating as a virtual host, you must create email aliases as part of a user’s account that specifies which email addresses across the virtually hosted domains will be sent to their mailbox. The first step in configuring your server as a virtual host is to check the Enable checkbox in the Hosting tab. Then add domains that the server will handle email for, much as you would for a local host alias. Next, you need to create user aliases that specify email addresses for the hosted virtual domains.
There are two ways to create email aliases in Mac OS X Server. One is at the command line by creating them as you would in Postfix. If you plan to use any of the features of Postfix beyond those discussed in this series or integrated into Mac OS X Server by Apple (such as sieve filtering), you should create aliases from the command line. However, be aware that these will be more difficult to manage and will not be listed as part of the user’s account in WorkGroup Manager. Therefore, they might not be easily identified by other administrators.
The simpler method to create an email alias is to simply add a short name to a user’s account in WorkGroup Manager. For virtual domains, you need to include both the user portion (before the @ symbol) and the domain name for the address. After that is done, email sent to the virtually hosted address is delivered to the person’s email account.