Name

${ntries}

Synopsis

When a message begins life and delivery has not yet been attempted, the message is considered to have had zero delivery attempts. If the first delivery attempt fails, the message is deferred to the queue and marked as having had one delivery attempt. Thereafter, each time the message is fetched from the queue and delivery fails, the number of attempts is incremented. Each time the message is read from the queue, the number of delivery attempts is stored in the ${ntries} macro.

One use for this ${ntries} macro might be to bounce high-priority mail that fails on the first try. If it cannot be sent right away, perhaps such mail should be faxed, or followed up with a telephone call. Consider the following mc file lines that suggest one way to accomplish this:

LOCAL_CONFIG
C{persistentMacros} {X-Notice}
HX-Notice: $>CheckNotice
Kstore macro

LOCAL_RULESETS
SCheckNotice
R $*           $: $(store {X-Notice} $@ YES $)

Scheck_compat
R $*           $: $&{X-Notice}
R $*           $: $(store {X-Notice} $) $1
R YES          $: $(math l $@ $&{ntries} $@ 1 $)
R FALSE        $#error $@ 5.7.1 $: "550 X-Notice mail exceeded allowed tries"

Here, we set up our own ${X-Notice} macro as a private flag so that we can detect the presence of the X-Notice: header, even when the message is read from the queue. Under LOCAL_CONFIG, we first add the ${X-Notice} macro to the class $={persistentMacros} ($={persistentMacros}) which ensures that ${X-Notice} will retain its value despite the message being queued. We then use the H configuration ...

Get Sendmail, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.