Macro-Included Headers Don’t Survive Queueing

The inclusion of a header based on a macro’s value is guaranteed to work only when mail is first sent or delivered, and can fail if the message is queued. Consider, for example, the desire to include a header that prints one of the sendmail program’s macro values:

LOCAL_CONFIG
H?${dsn_envid}?X-ENVID: ${dsn_envid}

The intention here is to record the value of the DSN envelope identifier value in an X- header, if such an identifier was supplied during the SMTP transaction. If a message is received with a MAIL From: line such as the following, the envelope identifier and ${dsn_envid} macro’s value will be given the text following the ENVID= expression:

MAIL From: <bob@some.domain> ENVID=1234abcd5678

When this message is received, the ${dsn_envid} macro will contain a value (the string 1234abcd5678) which will cause the X-ENVID: header to be given a value:

X-ENVID: 1234abcd5678

If this message cannot be delivered right away and is deferred to the queue instead, the previous header will be stored in the queue like this:

H?${dsn_envid}?X-ENVID: 1234abcd5678

Note that the original mc file’s ?${dsn_envid}? test is included in the queue file. When this message is later delivered, the ${dsn_envid} macro will not have a value. That macro is given a value only when the message is first received with SMTP. As a consequence, when the message is delivered from the queue, the ${dsn_envid} macro will lack a value and thus the X-ENVID: header will not be included ...

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.