home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeTCP/IP Network AdministrationSearch this book

10.3. sendmail Aliases

It is almost impossible to exaggerate the importance of mail aliases. Without them, a sendmail system could not act as a central mail server. Mail aliases provide for:

  • Alternate names (nicknames) for individual users

  • Forwarding of mail to other hosts

  • Mailing lists

sendmail mail aliases are defined in the aliases file.[110]

[110]The location of the file is defined in the ALIAS_FILE parameter in the sendmail m4 configuration.

The basic format of entries in the aliases file is:

 alias: recipient[, recipient,...]

alias is the name to which the mail is addressed, and recipient is the name to which the mail is delivered. recipient can be a username, the name of another alias, or a full email address containing both a username and a hostname. Including a hostname allows mail to be forwarded to a remote host. Additionally, there can be multiple recipients for a single alias. Mail addressed to that alias is delivered to all of the recipients, thus creating a mailing list.

Aliases that define nicknames for individual users can be used to handle frequently misspelled names. You can also use aliases to deliver mail addressed to special names, such as postmaster or root, to the real users that do those jobs. Aliases can also be used to implement simplified mail addressing, especially when used in conjunction with X records.[111]

[111]Chapter 8, "Configuring DNS" discusses MX records.

This aliases file from crab shows all of these uses:

# special names 
postmaster: clark 
root: norman 
# accept firstname.lastname@wrotethebook.com 
rebecca.hunt: becky@rodent 
jessie.mccafferty: jessie@jerboas 
anthony.resnick: anthony@horseshoe 
andy.wright: andy@ora 
# a mailing list 
admin: kathy, david@rodent, sara@horseshoe, becky@rodent, craig, 
       anna@rodent, jane@rodent, christy@ora 
owner-admin: admin-request 
admin-request: craig

The first two aliases are special names. Using these aliases, mail addressed to postmaster is delivered to the local user clark, and mail addressed to root is delivered to norman.

The second set of aliases is in the form of firstname and lastname. The first alias in this group is rebecca.hunt. Mail addressed to rebecca.hunt is forwarded from crab and delivered to becky@rodent. Combine this alias with an MX record that names crab as the mail server for wrotethebook.com, and mail addressed to rebecca.hunt@wrotethebook.com is delivered to becky@rodent.wrotethebook.com. This type of addressing scheme allows each user to advertise a consistent mailing address that does not change just because the user's account moves to another host. Additionally, if a remote user knows that this firstname.lastname addressing scheme is used at wrotethebook.com, the remote user can address mail to Rebecca Hunt as rebecca.hunt@wrotethebook.com without knowing her real email address.

The last two aliases are for a mailing list. The alias admin defines the list itself. If mail is sent to admin, a copy of the mail is sent to each of the recipients (kathy, david, sara, becky, craig, anna, jane, and christy). Note that the mailing list continues across multiple lines. A line that starts with a blank or a tab is a continuation line.

The owner-admin alias is a special form used by sendmail. The format of this special alias is owner-listname where listname is the name of a mailing list. The person specified on this alias line is responsible for the list identified by listname. If sendmail has problems delivering mail to any of the recipients in the admin list, an error message is sent to owner-admin. The owner-admin alias points to admin-request as the person responsible for maintaining the mailing list admin. Aliases in the form of listname-request are commonly used for administrative requests, such as subscribing to a list, for manually maintained mailing lists. Notice that we point an alias to another alias, which is perfectly legal. The admin-request alias resolves to craig.

sendmail does not use the aliases file directly. The aliases file must first be processed by the newaliases command. newaliases is equivalent to sendmail with the -bi option, which causes sendmail to build the aliases database. newaliases creates the database files that are used by sendmail when it is searching for aliases. Invoke newaliases after updating the aliases file to make sure that sendmail is able to use the new aliases.[112]

[112]The AutoRebuildAliases option causes sendmail to automatically rebuild the aliases database -- even if newaliases is not run. See Appendix E, "A sendmail Reference".



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.











??????????????@Mail.ru