The behavior of the sendmail program requires that two specific aliases (Postmaster and MAILER-DAEMON) be defined in every aliases file. Beginning with V8.7 sendmail, aliases that contain a plus character can be used to route mail on the basis of special needs. Also, beginning with V8.7 sendmail, databases that allow duplicates can be declared to help automate the creation of those files.
RFC822 requires every site to accept for delivery mail that is addressed to a user named postmaster. It also requires that mail accepted for postmaster always be delivered to a real human being - someone who is capable of handling mail problems. If postmaster is not an alias, or a real user, sendmail syslog(3)'s the following error:
can't even parse postmaster!
Unless a site has a real user account named postmaster, an alias is required in every aliases file for that name. That alias must be a list of one or more real people, although it may also contain a specification for an archive file or filter program. One such alias might look like this:
postmaster: bill, /mail/archives/postmaster, "|/usr/local/bin/notify root@mailhost"
postmaster is lowercase. Because all aliases
are converted to lowercase for lookup,
POSTMASTER could have been used for equal effect.
Note that there are three aliases to the right of the colon: a local user
bill, the full path of a file onto which mail
messages will be appended, and a program to
root at the machine
postmaster mail has arrived on the local machine.
As a convention, the special name postmaster
can also be that of the user who gets duplicate copies
of some bounced mail.
This is enabled by using the
(see Section 34.8.46, PostmasterCopy (P)) in the configuration file:
OPpostmaster pre-V8.7 O PostmasterCopy=postmaster V8.7 and above
To disable sending copies of bounced mail to a special user (perhaps to protect privacy), omit this option from the configuration file.
Note that V8 sendmail does not send to the postmaster
copies of error mail
that include a
Precedence: header with a value less than
zero, like junk, bulk, or list used by mailing lists.
OPmail-errors pre-V8.7 O PostmasterCopy=mail-errors V8.7 and above
and the corresponding aliases file entry is declared as
mail-errors: "|/etc/mail/filter postmaster"
filter can be designed that discards
all common error messages, such as mistyped addresses, and forwards
what remains to
Many sites have developed just such filters. One is distributed with the V8 sendmail source in the file contrib/mmuegel. Written by Michael S. Muegel of Motorola's Corporate Information Office, it is a shar(1) file of several useful perl(1) scripts. One (postclip.pl) is a tool that filters out the body of bounced mail messages to prevent postmasters from potentially violating the privacy of senders. It tries to retain all headers, no matter how deeply they are buried in what appears to be the message body.
When mail is bounced, the notification of failure is always
shown as being from
the sender whose name is defined by the
$n macro (see
Section 31.10.26, $n). Traditionally,
that macro is given the value
That tradition is enforced by the fact that if
$n is not
defined, it defaults to
There needs to be an alias for whatever name is defined for
$n, because users occasionally make the mistake
of replying to bounced mail. Two typical aliases are
mailer-daemon: postmaster mailer-daemon: /dev/null
Here, the name to the left of the colon should be whatever
was defined for
$n in the configuration file,
traditionally (and recommended to be)
The first alias forwards all
mailer-daemon reply mail to
the postmaster. Many site administrators prefer the second,
which discards such mail by using /dev/null.
Plussed users is a simple way to do more versatile aliasing. It is available only with V8.7 sendmail and above, and it requires that you use a configuration file that comes with V8 sendmail. To illustrate its use, consider the need to have mail routed to different sets of administrators depending on how the address root is augmented:
root: hans, george root+db: root, email@example.com root+*: root, firstname.lastname@example.org
Here, the first line shows a normal sort of alias in which mail sent to root will instead be delivered to the local users hans and george. The second line is still not all that special, because we could as easily have used an alias such as root_db to accomplish the same thing. It sends mail to root+db to the local root users and to the database administrators in another department, email@example.com.
The third line is where things start to get interesting. The
in it will match anything or nothing following the plus,
so mail sent to root+ will be sent both to the local
root users and to the central administrators
at firstname.lastname@example.org. But so will anything following the plus
that is not
db, such as root+foo.
+* form is omitted:
root: hans, george root+db: root, email@example.com
the default for plussed addresses other than root+db becomes root. That is, when sendmail looks up a plussed address (for example root+foo) it does so in the following order:
Look for an exact match. Does root+foo match root+db?
Look for a wildcard match. Does root+
* exist? If so, use that
alias for root+foo.
Look for a base match. Does the root of root+foo exist as an alias? If so, use that alias for root+foo.
Note that plussed users is a simple mechanism that is intended to solve simple needs. In distributing a common aliases file to many machines, for example, plussed users can furnish a hook that allows customization based on simple alias extensions. Because plussed users is simple, attempts to extend it to handle complex needs will likely fail. If your needs are complex, consider using the User Database (see Section 33.5, "The User Database") or writing custom hooks in checkcompat() (see Section 20.1, "How checkcompat() Works") instead.
staff: bob staff: george
Running newaliases on this file would produce the following error message and would cause the first entry to be ignored:
Warning: duplicate alias name
Sometimes, however, it is advantageous to produce an alias file with duplicates. Consider this abstract from a newuser adding script:
if [ $GROUP = "staff" ] then echo "staff: $USER" >> /etc/aliasdir/groups fi
Here, we seek to add the user whose login name is stored in
$USER to the mailing list called
To prevent sendmail from complaining, we declare the
/etc/aliasdir/groups file like this in the configuration
O AliasFile=dbm:-A /etc/aliasdir/groups
dbm tells sendmail this is
a ndbm(3) type file (it could also be
for db(3) type files). The
-A switch tells sendmail to
append duplicates rather than rejecting them.
Too illustrate, revisit the earlier alias file:
staff: bob staff: george
The first alias line is read and stored normally with this key and value pair:
staff bob key value
The second line is then appended to the first line, because of the
staff bob,george key value
The comma is intelligently inserted by sendmail.
Although this technique can simplify the maintenance of some alias files, it should not be overused. Each append requires the prior entry to be read, the space for it and the new entry to be allocated, the old and new entries to be concatenated, and the result to be stored in such a way as to replace the original. This process slows down sendmail noticeably when it rebuilds large files with many duplicates.