System Administration Guide, Volume 3

Administering Mail Alias Files

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, or on the local system. Or you can use the AdminTool's Database Manager application to perform these tasks on the aliases database.

In addition, database files can be created for the local mail host using makemap. Using these database files does not provide the all of the advantages of using a name space like NIS or NIS+, but retrieving the data should be faster than using local files.

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.

Example--Listing All 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.


Example--Listing 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

  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. Optional: If necessary, initiate a NIS+ table

    If you are creating a completely new NIS+ mail_aliases table, you must first initiate the table. Type aliasadm -I and press Return.

  4. 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"
  5. Type aliasadm -m alias and press Return.

    This displays the entry you created.

  6. 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, vi is the default editor.

  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.

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 "How to Set 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.

How to Set Up a Local Mail Alias File

  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 "How to Set 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.

How to Create a Keyed Map File

  1. Using the editor of your choice, create the input file.

    Entries can look like the following:


    sandy@newdomain.com     ssmith@newdomain.com
    ssmith@olddomain.com    error:nouser No such user here
    @olddomain.com          %1@newdomain.com

    In this sample, the first entry redirects mail to a new alias; the second entry creates a message when an incorrect alias is used; and the last entry redirects all incoming mail from olddomain to newdomain.

  2. Make the database file.


    # /usr/sbin/makemap -o dbm newmap < newmap
    

    -o

    Append to instead of overwriting the file. See makemap(1M) for a list of the options available.

    dbm

    Selects the dbm database type. Other map types are btree or hash.

    newmap

    Is the name of the input file and the first part of the name of the database file. If the dbm database type is selected, then database files are created using a .pag and a .dir suffix. For the other two database types, the file name is followed by .db.

How to Set 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 acts 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. After 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.