When sendmail receives a message via SMTP, it
can also receive information about how it should handle a bounce.
That information is included as part of an envelope-sender
declaration:
RCPT To:<address> NOTIFY=how
Here, the RCPT TO: command specifies an envelope
recipient's address. Following that address is the
keyword NOTIFY=, followed by one or more of four possible keywords:
success, failure,
never, and delay (see -N for a more complete description of NOTIFY= and
its keywords).
The keywords specified are made the value of the
${dsn_notify} macro. If no NOTIFY= is specified,
the ${dsn_notify} macro is undefined (NULL). If
multiple RCPT TO: commands are issued during a single SMTP session,
each command will update the ${dsn_notify} macro
in turn, overwriting the prior RCPT TO: command's
value.
The ${dsn_notify} macro is also given a value if
the -N command-line switch (-N) is used to set the NOTIFY= keyword during
mail submission.
One use for this ${dsn_notify} macro might be to
log every instance when notification of success is requested. One way
to do this is with a syslog map in the
check_compat rule set:
LOCAL_CONFIG
Klog syslog -D -LNOTICE
LOCAL_RULESETS
Scheck_compat
R$* $: $&{dsn_notify} $| $1
Rsuccess $| $* $| $* $: $(log dsn=success, recipient=$2, sender=$1 $)
Here, we declare a syslog map (syslog) with the K configuration
command (Section 23.2) in the LOCAL_CONFIG part of
your mc file. The -D tells
sendmail to not syslog if the message is being
deferred. The -L configuration command tells
sendmail to syslog at level
LOG_NOTICE (Section 14.3.1).
The LOCAL_RULESETS part of your mc file declares
the check_compat (Section 7.1.4)
rule set, which is called just after the check for too large a size
(as defined by M=, M=).
The workspace passed to check_compat is the sender
and recipient addresses separated by a $|
operator. The first rule simply places the value in the
${dsn_notify} macro at the beginning of the
workspace and separates that value from the rest of the workspace
with another $| operator.
The second rule looks for the success keyword. If
it is found, the log map is called to syslog the
three pieces of information shown.
${dsn_notify} is transient. If it is defined in
the configuration file or in the command line, that definition can be
ignored by sendmail. Note that a
$& prefix is necessary when you reference this
macro in rules (that is, use $&{dsn_notify},
not ${dsn_notify}).