Milter smfi_addheader()

Conditionally insert a header All sendmail versions

To add a header to the existing headers in a message you may use either this smfi_addheader() routine or the smfi_insheader() routine (Milter smfi_insheader() on page 1192). This routine is conditional in that it will replace some headers and insert others, whereas the smfi_insheader() routine is unconditional and always inserts headers. With this smfi_addheader() special logic inside sendmail scans headers to see whether the new header name already exists. If that header name exists, and if that header is not a trace header (such as Received:), and if that header is not an X- header nor one added by another Milter, sendmail will silently replace the existing named header’s value with the new value, rather than adding the new header.[448]

Before you may add headers, you must first declare your intention to do so by including the SMFIF_ADDHDRS flag to the flags portion of the smfiDesc structure:

struct smfiDesc smfilter =
{
    ...
    SMFIF_ADDHDRS,/* flags */
    ...

Failure to include this flag causes smfi_addheader() to return MI_FAILURE every time it is called.

You add headers to a message by calling this smfi_addheader() routine from inside your xxfi_eom() function (Milter xxfi_eom() on page 1215):

ret = smfi_addheader(ctx, name, value);

The first argument is the usual ctx connection-context pointer. It is the same ctx pointer that was passed to the enclosing xxfi_eom() function. It may not be NULL and must be a valid ...

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.