This is the BSDA Study Guide Book written via a
This is a work in progress. You may contribute to or discuss this specific page at http://bsdwiki.reedmedia.net/wiki/Create_or_modify_email_aliases_for_Sendmail_or_Postfix.html.
Create or modify email aliases for Sendmail or Postfix
Understand when to create an email alias
and how to do so for either Sendmail or Postfix.
It is frequent situation that being a system administrator you have to receive information sent
to couple of e-mail addresses, like ex.
email@example.com. One way of doing so is maintaining an e-mail account for each
address and frequently checking all of them for new mail. Although it would work, in the long run
it would cause unnecessary complication to the e-mail account system. The other way is using
E-mail alias is an entry in
aliases file. It explains to MTA which existing e-mail account
should receive mail bound for given e-mail address. It is useful for both permanent and temporary
aliases, as well as for keeping small mailing lists. Some e-mail aliases are required by RFC 2142.
Both Postfix and Sendmail use the
/etc/mail/aliases file to define e-mail aliases. The file format
is similar for both MTAs. The names of existing accounts and aliases can be specified without
@ and domain name for local accounts.
The MTA actually does not read directly from
/etc/mail/aliases file. Instead, it reads information
/etc/mail/aliases.db, the random access data base. Thus after every modification of the file
aliases the data base has to be rebuild by simply executing command newaliases(1). There is
no need to restart the MTA daemon.
Postfix, as an addition, includes a postalias(1) command for creating, quering or updating alias
databases. To see given alias entry execute postalias with -q flag followed by an alias name.
Please note, that it have to be a name used as a key in alias database.
/etc/mail/aliases file aliases are specified in the format of
<alias name>: <existing account>.
<existing account> should be substituted by one or more account names in form of a coma separated list.
<alias name> acts as a key in alias database.
Sample alias for an administrator that should receive root's mail:
Sample alias for an e-mail
firstname.lastname@example.org that should be delivered to all the administrators:
admin: mike, john, stacy
Now, let's say we have three senior administrators: Mike, John, Stacy, and also two junior administrators:
Jane, and Paul. All of them should receive mail from
admin account, but only senior administrators should
receive mail also from
abuse accounts. Furthermore, there's also Jake who should receive
abuse information as well. Alias configuration should look like this:
abuse: root, jake
admin: senior, junior
senior: mike, john, stacy
junior: jane, paul
practice alias pointing to your own account, rebuild data base and check whether you'll receive
mail sent to this account.
- With Postfix MTA use postalias(1) to display given (-q flag), and all (-s flag) entries in alias
newaliases(1), aliases(5), postalias(1)