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"
Note that there are three aliases to the right of the colon: a local user
As a convention, the special name
can also be that of the user who gets duplicate copies
of some bounced mail.
This is enabled by using the
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
does not send to the postmaster
copies of error mail
that include a
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"
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
That tradition is enforced by the fact that if
There needs to be an alias for whatever name is defined for
mailer-daemon: postmaster mailer-daemon: /dev/null
Here, the name to the left of the colon should be whatever
was defined for
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, firstname.lastname@example.org root+*: root, email@example.com
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, firstname.lastname@example.org .
The third line is where things start to get interesting. The
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:
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
O AliasFile=dbm:-A /etc/aliasdir/groups
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.