Milter smfi_insheader()

Unconditionally insert a header V8.13 and later

Prior to V8.13, the only way to add a header to the message was by using either the smfi_addheader() (Milter smfi_addheader() on page 1184) or the smfi_chgheader() (Milter smfi_chgheader() on page 1188).

The smfi_addheader() routine, however, had its limitations. Using its special logic, it examined existing header names to determine whether the new name already existed, and, if it was neither a trace header (such as Received:) nor an X- header, nor one added by another Milter, sendmail would silently replace that existing header’s value with the new value, rather than adding the new header.

Beginning with V8.13, the new smfi_insheader() routine allows you to unconditionally insert a new header, even if that header already exists in the message. But before you can use this new smfi_insheader() routine, you must add the SMFIF_ADDHDRS flag to the flags part of the your smfiDesc declaration:

struct smfiDesc smfilter =
{
          ...
    SMFIF_ADDHDRS,    /* flags */   ← add here

Omitting this flag will cause smfi_insheader() to fail.

The smfi_insheader() routine is used like this.

ret = smfi_insheader(ctx, index, name, value);

The smfi_insheader() routine’s first argument is a common context pointer, ctx. The next argument is index, an index into the list of existing headers. If index is zero, the new header will be added at the beginning of the list, before the first existing header. If index is greater than the number of existing headers, ...

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.