unix web hosting

Using the VPS v2 Virtual Server e-mail system, you can create e-mail aliases, (forwarding addresses). An alias forwards all incoming mail to one or more specific e-mail addresses, to one or more pre-determined recipients.

Aliases are used to create handy replacements for difficult-to-remember or long addresses. Aliases can also be used to establish a set of generic addresses such as webmaster@your_company.com or info@your_company.com. Establishing a set of aliases like the following promotes an image of professionalism (even if each alias points to the same recipient):

  • sales@your_company.com
  • service@your_company.com
  • jobs@your_company.com

Since a single alias can point to multiple recipients, aliases can be used to create simple mailing lists or announcement boards that point to appropriate sets of individuals, allowing the alias address to be used as a "broadcast" address for the group:

  • everyone@your_company.com
  • marketing@your_company.com
  • engineering@your_company.com

If you have a large alias file, add comments to avoid confusion. Any lines that begin with the # character are considered a comment and are ignored.

To create an alias, add the alias to the /etc/mail/aliases file and type make to generate the aliases.db file.

Creating an Alias for a Local User
To create an alias for a local user:
    1. Go to /etc/mail.
    2. Invoke an editor for the /etc/mail/aliases file and add the following line, replacing “alias” with the alias name, and “recipient” with a simple user name.
    3. alias: recipient
      For example:
      webmaster: ted

Type newaliases to rebuild the access database only.

Creating an Alias for an Off-Site Recipient
To create an alias for an off site recipient:
    1. Go to /etc/mail.
    2. Invoke an editor for the /etc/mail/aliases file and add the following line, replacing “alias” with the alias name, and “recipient” with a full e-mail address.
      alias: recipient
      For example:
      sales: tony@hotshotmail.com
    3. Type newaliases to rebuild the access database only.

Note: Do not worry about multiple aliases, or one alias actually pointing to another alias. Sendmail performs multiple lookups to determine the recipient.

You should begin each alias at the start of the line, because lines begin each alias at the start of the line; lines that begin with a space or tab are considered continuation lines. The colon separating the alias and the recipient must be on the same line as the alias, and it may be preceded or followed by spaces or tabs.

Creating a Mailing List
Using the /etc/mail/aliases file, you can create mailing lists that include many recipients. Mailing lists save time. You can either create a simple mailing list, or you can create a more sophisticated mailing list that you are able to edit independently of the alias file.

The :include: statement causes the contents of a separate file to be read in, or included, in the aliases file. This allows the recipient list to be stored in an outside file where it can be manipulated independently of the aliases file.

Edit the /etc/mail/aliases file by typing in the form of:

alias: recipient1, recipient2, recipient3, recipient4,...

Creating a Mailing List with :include:
To create a mailing list using the include statement:
    1. Go to /etc/mail.
    2. Edit the /etc/mail/aliases file by typing in the form of:
      alias: :include:/pathname
      The /pathname is the virtual pathname of the file. For example:
      subscribers: :include:/etc/subscribers.list
    3. Type newaliases to rebuild the access database only.

The file referenced by include is a text file containing a list of recipient addresses. Each line is a list of one or more recipient addresses. Multiple addresses appearing on a line should be separated by commas. Like the /etc/mail/aliases file, any line that begins with a # character is considered a comment and is ignored, as are blank lines.

For more information about software that enables you to create automated mailing lists, see Majordomo (http://www.majordomo.com). Majordomo works with the /etc/mail/aliases file. It automates address addition and removal of recipients of the mailing list through the use of the :include: statement.

Virtmaps
Virtmaps, or e-mail address mappings are similar to aliases but are tailored to virtual host domain names. VPS v2 Virtual Servers that have one or more domain names associated with them in addition to their primary domain name use virtmaps to organize their aliases.

Aliases do not incorporate information about the hostname portion of an e-mail address, just the username portion. As a result, conflicts occur when two virtual domains have e-mail addresses with identical usernames, such as "webmaster". Virtual e-mail address mappings are designed to avoid these conflicts by ensuring that mail sent to "webmaster@domain1.com" and mail sent to "webmaster@domain2.com" do not collide, even though both domain names ("domain1.com" and "domain2.com") are associated with the same VPS v2 Virtual Server.

Creating a Virtmap
The first time you create a virtmap, you must create a virtusertable file that generates the virtusertable.db.
    1. Go to /etc/mail.
    2. Invoke an editor and name the file virtusertable.
      %vi virtusertable
    3. Type the following:
      address recipient
      where “address” is replaced with the full address you would like to route to and “recipient” is replaced with the recipient address. The actual virtusertable.sample file provides these examples:
      username@a.sample.hostname      localuser
      username@a.sample.hostname      specificuser@a.possibly.different.hostname
      @another.sample.hostname           specificuser@a.possibly.different.hostname
      @yet.another.sample.hostname      %1@a.possibly.different.hostname
    4. Types make to rebuild the database. Likewise, make will generate a new sendmail.cf file if there are changes to the sendmail.mc file, and then it will restart Sendmail.
      or
      Type makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable to rebuild the access database only.
    5. Add the source hostname to /etc/mail/local-host-names so that Sendmail will accept mail for the source hostname. If the domain was added to your account through ordering, the domain should already be in this file.
      % cd /etc/mail/
      % vi local-host-names
      Note: You must include the @ symbol in front of any domain, if you do not specify the entire e-mail address.
Sample of grouped virtmaps
In the following sample the address mappings are grouped together by domain name. The first address mapping in the "abc.com" group is redirecting mail to a non-local user. The second address mapping is directing mail to a local user.
#abc.com mappings
bob@abc.com                bob@aol.com
webmaster@abc.com          carol
#xyz.com mappings
bob@xyz.com                bob
webmaster@xyz.com          john

Note: Unlike the /etc/mail/aliases file, there is no colon character between the address and the recipient in the /etc/mail/virtusertable file.


Using a Catchall
A wildcard address mapping serves as a “catchall” that matches any address at a hostname that is not already explicitly listed.
    1. Go to /etc/mail.
    2. Invoke an editor for the virtusertable file.
      % vi virtusertable
    3. Type the following:
      @hostname recipient
      where hostname is replaced with the hostname you want to create the wildcard for, and recipient is replaced with the recipient’s address.
    4. Save the file and close the editor.
    5. Types make to rebuild the database. Likewise, make will generate a new sendmail.cf file if there are changes to the sendmail.mc file, and then it will restart Sendmail.
      or
      Type makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable to rebuild the access database only.
      The following is a sample virtusertable file with catchalls:
      #abc.com mappings
      bob@abc.com          bob@aol.com
      webmaster@abc.com    carol
      @abc.com             carol
      #xyz.com mappings
      bob@xyz.com          bob
      webmaster@xyz.com    john
      @xyz.com             bob

Note: Always place catchalls at the end of a hostname section in the /etc/mail/virtusertable file to emphasize their nature as a default recipient (if none of the previous mappings match).

Forwarding root’s mail to the Administrative User
For security reasons, the user root has no mail privileges. Instead, messages for root are configured by default in the aliases file, to be delivered to the Administrative User.

If you create a catchall, the alias entry for the Administrative user to receive e-mail for the root user will no longer work. Instead, e-mail for the root user will be delivered to the owner of the catchall. To solve this problem, you must create a virtmap for entry for each domain, including the primary and subhosted domains, with root@domain.name as the e-mail address and the Administrative user as the recipient.

The following is an example of how this should look in the virtusertable:

root@abc.com         admin
root@xzy.com         admin
@abc.com             carol
@xyz.com             bob
Combining Virtmaps and Aliases
This is the order in which incoming mail is read as it is routed:
Virtmaps  >  Aliases  >  Users  >  Bounce

When a piece of new mail arrives, address mappings are processed first before aliases are checked. After the address mapping process is complete and a local recipient has been determined, the aliases database is checked next to see if the recipient exists as an alias. If so, the message is routed to the target of the alias. If not, the recipient must exist as a local username, and a delivery attempt is made to place the message in that incoming mailbox.

Differences between Virtmaps and Aliases
Perhaps the most important difference between virtmaps and aliases is that Sendmail performs repeated lookups in /etc/mail/aliases until it completely resolves the recipient address, but performs only one database lookup in /etc/mail/virtusertable file when handling virtmaps.

The right-hand portion of an /etc/mail/virtusertable line should consist solely of a recipient address and must not contain any of the more advanced features. Items such as :include: statements, delivery to a file (signaled by a / character), or delivery to a program (signaled by a | character) may not be used in virtusertable.

The right-hand portion of a /etc/mail/virtusertable line (the recipient portion) must not depend on the left-hand portion (the address portion) of any other line.

Unlike the aliases file, multiple recipients must not be listed in a single address mapping.


Virtmaps Summarized
If you have only one domain (the primary domain) pointing to your VPS v2 Virtual Server, then use of virtusertable is not necessary.
  • Virtmaps are stored in /etc/mail/virtusertable.
  • After adding an entry to the virtusertable, rebuild the database using the make command.
  • Type address maps like the following example:
    address        recipient
    For example:
    webmaster@abc.com          john
  • Do not include colons in address maps and include only one user on the right side. If multiple recipients are needed on the right, then specify the name of an alias on the right hand side, and then create the alias in /etc/mail/aliases with the multiple recipients.
  • The catchall for a domain should be listed last.
Blocking E-mail from Specific Hosts (Spammers)
To block e-mail from spammers:
    1. Go to /etc/mail.
    2. Edit the /etc/mail/access file, using your preferred editor.
      % pico access.db
    3. Type the following:
      username@hostname    REJECT
      or
      hostname       REJECT
      12.34.56.78    REJECT
      12.34.56.79    REJECT
      or
      12.34          REJECT
      where “username” is the username of the sender, and “hostname” is the hostname portion of the sender's address, 12.34.56.78 is the IP address of the sender, and 12.34 is the IP block of the sender.
    4. Save the file and close the editor.
    5. Types make to rebuild the database. Likewise, make will generate a new sendmail.cf file if there are changes to the sendmail.mc file, and then it will restart Sendmail.

      or
      Type makemap hash /etc/mail/access < /etc/mail/access to rebuild the access database only.

Maintaining the E-mail Log File
Your e-mail log files are in /var/log/maillog. For information on tools to use in maintaining your e-mail log file, see Chapter 9.

Important Commands, Directories, and Files
The following table describes commands, directories, and files used to manage the e-mail server.

Name

Type

Description

cd /etc/mail make

command

Rebuilds the aliases, access, and virtusertable files. It is not necessary to restart Sendmail after running this command.

cd /etc/mail make restart

command

Restarts the current Sendmail processes.

cd /etc/mail

make stop

command

Stops the current Sendmail processes.

cd /etc/mail make start

command

Starts Sendmail.

restart_send
mail

command

Restarts both Sendmail daemons (accepting connections and queuerunner) and also restarts the SMTP authentication daemon, saslauthd.

/etc/mail/
access

file

Lists mail addresses or domains the server is to refuse message from.

/etc/mail/
aliases

file

Lists aliases

/var/log/
maillog

file

Contains log of e-mail messages

/etc/mail/
sendmail.cf

file

The Sendmail main configuration file

/etc/mail/
virtusertable

file

Lists virtmaps and catchalls

Order of Mail Delivery:  virtmaps  >  aliases  >  users  >  bounce


For More Information
For more information about the topics discussed in this chapter, Visit our Technical Support Pages

http://www.sendmail.org

Hosting  ::  Web Design  :: Server Administration  ::  Tech Support  ::  Contacts
Data Centers  ::  Tier I Global IP Network  ::  SLA/Contracts  ::  Search  ::  Account Login