Aliases

Mail aliases allow us to define alternative names for users or groups of users. Each alias consists of a name and an associated array of one or more user names. They are stored in a file named /etc/mail/aliases. Historically, this was named /etc/aliases, and in fact a link still exists to allow /etc/aliases to be used.

It's useful to create aliases for many reasons, some of which are listed below:

  • Aliases allow us to provide a consistent look to our external email addresses, regardless of the login name assigned to each user. We'll use them to provide an external address for all users to allow them to receive email using a “firstname.lastname” address.

  • We can make allowances for names that may be easily confused or shortened. For example, we'll add aliases for “msmith,” so that he'll receive mail sent to “Mike,” “Michael,” or even “Micheal” (as his name is commonly misspelled).

  • They allow us to send mail easily to a group of people. By assigning a number of addresses to an alias, we can direct mail by department (sales, marketing, etc.) and make sure that important mail isn't missed if someone is away. We'll do this for any backup-related mail.

  • We can “hide” internal user names from the outside world. Common examples of these are the “postmaster” and “webmaster” accounts.

After we've made the changes, our file is as follows:

xenon# cat /etc/mail/aliases
#
# std alias for returned messages
#
MAILER-DAEMON: postmaster
#
# aliases for the users
#
Mike.smith: msmith
Michael.smith: msmith
Micheal.smith: msmith
John.green: jgreen
#
# add an alias for any backup messages
#
backup: sysadmin,msmith
#
# create the common accounts
#
postmaster: sysadmin,root
webmaster: sysadmin,root
xenon#

Although the aliases file is an ASCII text file, sendmail actually requires a DBM-based database. The aliases database is stored in two binary files named /etc/mail/aliases.dir and /etc/mail/aliases.pag, which are generated using the newaliases command as shown below:

xenon# newaliases
/etc/mail/aliases: 8 aliases, longest 15 bytes, 148 bytes total
xenon#

If the system is configured with a naming service, the aliases database can be incorporated into it. We discussed how to do this in Chapter 12, “Naming Services and NIS,” but we'll quickly run through the process using our NIS server tin as an example:

tin# cd /var/yp
tin# make
updated aliases
pushed aliases
tin#

Next we'll update /etc/nsswitch.conf so that it contains the following entry, which checks the local aliases first, followed by the NIS map:

tin# grep aliases /etc/nsswitch.conf
aliases:         files nis
tin#

Now that we have an aliases map, we need to check that it works by sending a number of mails once more. They should be addressed to some of the alias names, such as backup or John.Green, for example.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset