Mail Administration Guide

Creating Mail Aliases

You can use the aliasadm command to create mail aliases for a user. Mail aliases must be unique within the domain. This section tells you how to use command lines to search the mail aliases table for aliases, and to create mail aliases for NIS+, NIS, DNS, or on the local system.

Or you can use the Administration Tool's Database Manager application to perform these tasks on the aliases database.

Which type of file to use depends on who will be using the alias and who needs to be able to change the alias. Each type of alias file has unique format requirements. Each of these will be defined in the following sections.

Mail Alias Files

You can use any of the following files to maintain aliases. A combination of these files are used in many sites.

.mailrc Aliases

Aliases listed in a .mailrc file are accessible only by the user who owns the file. This allows users to establish an alias file they control and that is usable only by its owner. Aliases in a .mailrc file adhere to the following format:


alias aliasname value value value ...

where aliasname is the name the user will use when sending mail, and value is a valid email address.

If a user establishes a personal alias for scott that does not match the email address for scott in the name space, mail will be routed to the wrong person when other people try to reply to mail generated by that user. The only workaround is to use any of the other aliasing mechanisms.

/etc/mail/aliases

Any alias established in the /etc/mail/aliases file can be used by any user who knows the name of the alias and the host name of the system that contains the file. Distribution list formats in a local /etc/mail/aliases file adhere to the following format:


aliasname: value,value,value...

where aliasname is the name the user will use when sending mail to this alias and value is a valid email address.

The aliases in the /etc/mail/aliases file are stored in text form. When you edit the /etc/mail/aliases file, run the newaliases program to recompile the database and make the aliases available in binary form to the sendmail program. Or you can use Administration Tool's Database Manager to administer the mail aliases stored in local /etc files.

Normally, the root user only can edit this file. If using the Administration Tool, then all users in group 14, which is the sysadmin group, will be able to change the local file. Another option is to create an entry like:


aliasname: :include:/path/aliasfile

where aliasname is the name the user will use when sending mail and /path/aliasfile is the full path to the file that includes the alias list. The alias file should include email entries, one entry on each line, and no other notations:


user1@host1
user2@host2

You can change the permissions on this file so that multiple users can alter the alias, without supplying root access or permissions to change data with the Administration Tool.

You can define additional mail files in /etc/mail/aliases to keep a log or a backup copy. The following entry stores all mail sent to aliasname in filename.


aliasname: /home/backup/filename

Note -

All mail files must be writable by daemon. To allow other users to deliver mail to this file, set the permissions so that the file is owned by a specific user, the group owner is daemon, and the file permissions are at least 0620.


You can also route the mail to another process. The following stores a copy of the mail message in filename and prints a copy.


aliasname: "|tee -a /home/backup/filename |lp"

NIS Aliases Map

All users in the local domain can use entries included in the NIS aliases map. The sendmail program can use the NIS aliases map instead of the local /etc/mail/aliases files to determine mailing addresses. See the nsswitch.conf(4) man page for more information.

Aliases in the NIS aliases map adhere to the following format:


aliasname: value,value,value...

where aliasname is the name the user will use when sending mail and value is a valid email address.

The NIS aliases map should contain entries for all mail clients. In general, only the root user on the NIS master can change these entries. This type of alias might not be a good choice for aliases that are constantly changing, but can be useful if the alias points to another alias file; as in this syntax example:


aliasname: aliasname@host

where aliasname is the name the user will use when sending mail and host is the host name for the server that contains an /etc/mail/alias file.

NIS+ mail_aliases Table

The NIS+ mail_aliases table contains the names by which a system or person is known in the local domain. The sendmail program can use the NIS+ mail_aliases table instead of the local /etc/mail/aliases files to determine mailing addresses. See the aliasadm(1M) and nsswitch.conf(4) man pages for more information.

Aliases in the NIS+ mail_aliases table adhere to the following format:


alias:			expansion					[options		# "comments"]

Table 2-2 describes the four columns.

Table 2-2 Columns in the NIS+ mail_aliases Table

Column 

Description 

alias

The name of the alias 

expansion

The value of the alias or a list of aliases as it would appear in a sendmail /etc/mail/aliases file

options

Reserved for future use 

comments

Comments about an individual alias 

The NIS+ mail_aliases table should contain entries for all mail clients. You can list, create, modify, and delete entries in the NIS+ aliases table with the aliasadm command. Or you can use Administration Tool's Database Manager to administer NIS+ mail aliases.

If you are creating a new NIS+ aliases table, you must initialize the table before you create the entries. If the table exists, no initialization is needed. See "To List Individual Entries in the NIS+ mail_aliases Table " for information about how to create a NIS+ mail_aliases table.

To use the aliasadm command, you must be a member of the NIS+ group that owns the aliases table or the person who created the table.

How to List the Contents of an NIS+ Aliases Table

To use the aliasadm command, you must be either root, a member of the NIS+ group that owns the mail_aliases table, or the person who created the table.

To List the Entire Contents of the NIS+ mail_aliases Table

    Type aliasadm -l and press Return.

This lists the contents of the aliases table in alphabetical order by alias.


Note -

If you have a large aliases table, listing the entire contents can take some time. If you are searching for a specific entry, pipe the output through the grep command (aliasadm -l | grep entry) so that you can use the grep search capability to find specific entries.


To List Individual Entries in the NIS+ mail_aliases Table

    Type aliasadm -m alias and press Return.

The alias entry is listed.


# aliasadm -m ignatz
ignatz: ignatz@saturn # Alias for Iggy Ignatz

Note -

The aliasadm -m option matches only the complete alias name. It does not match partial strings. You cannot use metacharacters (like * and ?) with the aliasadm -m option. If you are interested in partial matches, type aliasadm -l | grep partial-string and press Return.


How to Add Aliases to a NIS+ mail_aliases Table From the Command Line

If you are creating a completely new NIS+ mail_aliases table, you first must initiate the NIS+ table.

To Initiate a NIS+ Table

    Type aliasadm -I and press Return.

To Add Aliases to a NIS+ mail_aliases Table From the Command Line

  1. Compile a list of each of your mail clients, the locations of their mailboxes, and the names of the mail server systems.

  2. Become root on any system.

  3. For each alias, type aliasadm -a alias expanded_alias [options comments] and press Return.

    This adds the aliases to the NIS+ aliases table.


    # aliasadm -a iggy iggy.ignatz@saturn "Iggy Ignatz"
  4. Type aliasadm -m alias and press Return.

    This displays the entry you created.

  5. Check that the entry is correct.

How to Add Entries by Editing a NIS+ mail_aliases Table

If you are adding more than two or three aliases, you might want to edit the NIS+ table directly.

  1. Compile a list of each of your mail clients, the locations of their mailboxes, and the names of the mail server systems.

  2. Become root on any system.

  3. Type aliasadm -e and press Return.

    The aliases table is displayed using the editor set with the $EDITOR environment variable. If the variable is not set, the vi editor is used.

  4. Type each alias on a separate line, using these formats:

    1. Type the aliases in any order, at any place in the table.

      The order is not important to the NIS+ mail_aliases table. The aliasadm -l command sorts the list and displays them in alphabetical order.

    2. Use the format alias: expanded_alias # ["option"# "comments"]

      If you leave the option column blank, type an empty pair of quotation marks ("") and then add the comments.

    3. End each line by pressing Return.

  5. Check that the entries are correct.

  6. Save the changes.

How to Change Entries in a NIS+ mail_aliases Table

  1. Become root on any system.

  2. Type aliasadm -m alias and press Return.

    The information for the alias is displayed.

  3. Type aliasadm -c alias expanded_alias [options comments] and press Return.

    The alias is changed using the new information you provide.

  4. Type aliasadm -m alias and press Return.

    The entry you created is displayed.

  5. Check that the entry is correct.

How to Delete Entries From a NIS+ mail_aliases Table

  1. Become root on any system.

  2. Type aliasadm -d alias and press Return.

    The alias is deleted from the NIS+ mail_aliases table.

Setting Up NIS mail.aliases Map

The /etc/mail/aliases file on a NIS master contains all names by which a system or person is known. The NIS master is searched if there is no match in the local /etc/mail/aliases files. The sendmail program uses the NIS master file to determine mailing addresses. See the aliases(4) man page.

You can either edit the file on each system or edit the file on one system and copy it to each of the other systems.

Aliases are in the following form:


name: name1, name2, ...

You can use aliases for local names or domains. For example, an alias entry for user fred who has a mailbox on the system saturn and who is in the domain planets would have this entry in the /etc/mail/aliases file:


fred: fred@planets

How to Set Up NIS mail.aliases Map

  1. Compile a list of each of your mail clients, the locations of their mailboxes, and the names of the mail server systems.

  2. Become root on the NIS master server.

  3. Edit the /etc/mail/aliases file, and make the following entries:

    1. Add an entry for each mail client.

    2. Change the entry Postmaster: root to the mail address of the person who is designated as postmaster.

      See "Setting Up the Postmaster Alias" for more information.

    3. If you have created a mailbox for administration of a mail server, create an entry for root:mailbox@mailserver.

    4. Save the changes.

  4. Edit the /etc/hosts file on the NIS master server and create an entry for each mail server.

  5. Type cd /var/yp and press Return.

  6. Type make and press Return.

    The changes in the /etc/hosts and /etc/mail/aliases files are propagated to NIS slave systems. It takes a few minutes, at most, for the aliases to take effect.

Setting Up Local Mail Aliases Files

The /etc/mail/aliases file on a local system contains all names by which a system or person is known. The sendmail program uses this file to determine mailing addresses. See the aliases(4) man page.

If your network is not running a name service, the /etc/mail/aliases file of each system should contain entries for all mail clients. You can either edit the file on each system or edit the file on one system and copy it to each of the other systems.

Aliases are of the form:


name: name1, name2, ...

You can create aliases for only local names--a current host name or no host name. For example, an alias entry for user ignatz who has a mailbox on the system saturn would have this entry in the /etc/mail/aliases file:


ignatz: ignatz@saturn

It is a good idea to create an administrative account for each mail server. You do this by assigning root a mailbox on the mail server and adding an entry to the /etc/mail/aliases file for root. For example, if the system saturn is a mailbox server, add the entry root: sysadmin@saturn to the /etc/mail/aliases file.

How to Set Up Local Mail Aliases Files

  1. Compile a list of each of your mail clients and the locations of their mailboxes.

  2. Become root on the mail server.

  3. Edit the /etc/mail/aliases file and make the following entries:

    1. Add an entry for each mail client.

    2. Change the entry Postmaster: root to the mail address of the person who is designated as postmaster.

      See "Setting Up the Postmaster Alias" for more information.

    3. If you have created a mailbox for administration of a mail server, create an entry for root: mailbox@mailserver.

    4. Save the changes.

  4. Type newaliases and press Return.

    This creates an alias file in binary form that sendmail can use. The file is stored in the /etc/mail/aliases.dir and /etc/mail/aliases.pag files.

  5. Copy the /etc/mail/aliases, the /etc/mail/aliases.dir, and /etc/mail/aliases.pag files to each of the other systems.

    When you copy all three files you do not need to run the newaliases command on each of the other systems.

    You can copy the files by using the rcp or rdist commands or by using a script that you create for this purpose. Remember that you must update all the /etc/mail/aliases files each time you add or remove a mail client.

Setting Up DNS Aliases Files

The DNS name service does not support aliases for individuals. It does support aliases for hosts or domains using mail exchange (MX) records and cname records. You can specify host names, domain names, or both in the DNS database. See the Solaris Naming Setup and Configuration Guide for more information about administering DNS.

How to Use DNS With sendmail

  1. Edit the /etc/nsswitch.conf file and make sure that the hosts entry includes the dns flag.

    The host entry must include the dns flag for the DNS host aliases to be used.

  2. Check for a mailhost entry.

    Make sure there is an entry for mailhost in the DNS database.

Setting Up the Postmaster Alias

Every system should be able to send mail to a postmaster mailbox. You can create a NIS or NIS+ alias for postmaster or create one in each local /etc/mail/aliases file. Here is the default /etc/mail/aliases entry:


# Following alias is required by the mail protocol, RFC 822
# Set it to the address of a HUMAN who deals with this system's
# mail problems.
Postmaster: root

To create the postmaster alias, edit each system's /etc/mail/aliases file and change root to the mail address of the person who will act as postmaster.

You might want to create a separate mailbox for the postmaster to keep postmaster mail separate from personal mail. If you create a separate mailbox, use the mailbox address instead of the postmaster's mail address when you edit the /etc/mail/aliases files.

How to Create a Separate Mailbox for postmaster

  1. Create a user account for the person designated as postmaster and put an asterisk (*) in the password field.

  2. Once mail has been delivered, type mail -f postmaster and press Return.

    The mail program will be able to read and write to the mailbox name.

How to Add the postmaster Mailbox to the Aliases

  1. Become root and edit the /etc/mail/aliases file on each system.

    If your network does not run NIS or NIS+, edit the /etc/mail/aliases file.

  2. Change the postmaster alias from root to Postmaster: postmastermailbox@postmasterhost and save the changes.

  3. On the postmaster's local system create an entry in the /etc/mail/aliases file that defines the name of the alias (sysadmin, for example) and includes the path to the local mailbox.

  4. Type newaliases and press Return.

    Or you could change the Postmaster: entry in the aliases file to a Postmaster: /usr/somewhere/somefile entry.