Linux VPS Getting Started Guide: Configuring E-mail
All user email boxes reside in the /var/spool/mail directory. The system automatically creates email boxes for server users. If
no other email routing settings (such as aliases or virtual user tables) are configured, by default the username of each user
functions as a valid email for all domains that resolve to the server. For example, if domain1.com and domain2.com resolve to
the server, for the user bob, both bob@domain1.com and bob@domain2.com would deliver email to the /var/spool/mail/bob email box.
The system checks for matches in email routing and addresses in the following order and delivers to the first match it finds:
- Virtual user tables ( or virtusertable)
- aliases
- users
This section discusses virtusertable, catchall, and alias configurations.
Note: To edit the virtusertable and aliases files, you must be the root user. You can
become the root user by typing su at the command line and supplying the root user password.
Virtual User Tables
Virtual user tables (or virtusertable) route the full email address (both sides of the "@") to a local user, alias, or remote
email address, but cannot direct to files or programs. Only aliases can route email to a file or program. A virtusertable consists
of the virtusertable and its destination, or direction. For example, a virtusertable for bob@domain1.com could be directed to the
user bob with the following virtusertable entry:
bob@domain1.com bob
Virtusertable enable you to create email addresses without the need to create a corresponding user. For example, a virtusertable
for bob@domain2.com could be directed to bob@remotedomain.com with the following virtusertable entry:
bob@domain2.com bob@remotedomain.com
In this example, remotedomain.com would indicate a remote domain which does not resolve to your Linux VPS account.
Specify virtusertable in the /etc/mail/virtusertable file, with one virtusertable entry per line. The virtusertable.sample file
provided with each server contains example virtusertable. You can change virtusertable settings by editing the virtusertable file
and then executing the vnewvirtusertable command from the command prompt to load the virtusertable into the system.
Any time you make a change to the /etc/mail/virtusertable text file, you will need to create a db file that sendmail can read. The
following command will create the /etc/mail/virtusertable.db file when run by a root user:
# makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable
Catchalls
Catchall virtusertable should be used sparingly. Spammers often send many emails to every conceivable address for a domain, often
numbering in the thousands. A catchall virtusertable would cause the system to receive all of these emails and direct them to the
recipient.
A catchall virtusertable directs all email not otherwise configured with a virtusertable for a given domain to a single recipient.
For example, the following catchall virtusertable would direct all email not configured with another virtusertable for the domain
company.com to the joe user:
@company.com joe
If no virtusertable exists for an email address, and a catchall virtusertable is configured for the domain, the system would route
all email sent to that address to the catchall virtusertable.
Aliases
Email aliases simply forward email to a user, another alias, email address, list of addresses, file, or program. Aliases enable
you to create email addresses without the need to create a corresponding user. For example, the following alias would forward
email sent to webmaster@domain.com to the stan user:
webmaster: stan
Aliases also enable you to send email to a list or to a program. For example, the following alias would forward email sent to
sales@corporation.com to the bob, joe, and stan users:
sales: bob,joe,stan
For long email lists, place the emails in a file, one address per line, and use the include option. For example, the following
alias would forward email sent to promotion@website.com to all addresses in the /lists/promotion file:
promotion: :include: /lists/promotion
Specify aliases in the /etc/aliases file, with one alias per line. You configure the aliases by editing the aliases file according
to your needs. After making changes to the file, execute the newaliases command from the command prompt to load the aliases into
the system.
The system only considers the first portion of the email address (before @) for aliases. To direct an entire email address to a
certain recipient, use a virtusertable.

|