Macros Force Header Inclusion

Beginning with V8.12, it is possible to add a header to a message by placing a sendmail macro between the ? characters instead of, or in addition to, using flags (see ?flags? in Header Definitions). But note that for V8.10 and V8.11 only, the ? character method was omitted, and only a macro could appear in that position:

H?flags?X-Added-Header:  valueall versions
H${macro name}X-Added-Header:  valueV8.10 and V8.11 only
H?${macro name}?X-Added-Header:  valueV8.12 and later
H?${macro name}flags?X-Added-Header:   valueV8.12 and later

In the last three examples, if the macro has a value (is defined and is non-null), the header will be added to the email message. If the macro lacks a value (was not defined or was defined to be an empty string), the header is not added to the message. The first and last examples cause the header to be added if a corresponding flag appears in the F= equate of the selected delivery agent.

Note that if the header is already in the message, it will remain there, regardless of whether the macro is defined, or whether a flag is in the appropriate F= equate.

To illustrate, consider dealing with a message that contains an illegally formed Message-Id: header:

LOCAL_CONFIG
Kstorage macro
HMessage-Id: $>ScreenMessageId
H?${MsgId}?X-Authentication-Warning: ${MsgId}
C{persistentMacros} {MsgId}

LOCAL_RULESETS
SScreenMessageId
R < $+ @ $+  >          $@ OK
R $*                    $: $(storage {MsgId} $@ Illegal Message-Id: $1 $)

The LOCAL_CONFIG part of this mc file ...

Get sendmail, 4th 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.