Milter smfi_chgheader()
Change and remove headers All sendmail versions
The smfi_chgheader
() Milter library
routine is used to change the value of existing
headers and to remove headers. To conditionally add
headers use smfi_addheader
() (Milter smfi_addheader()
on page 1184). To unconditionally add headers use
smfi_insheader
() (Milter smfi_insheader()
on page 1192).
Before you can modify header values, you first need to
declare your intent to do so by including the
SMFIF_CHGHDRS
flag in the flags
portion of the smfiDesc
structure:
struct smfiDesc smfilter =
{
...
SMFIF_CHGHDRS,
/* flags */
...
Failure to include this flag causes smfi_chgheader
() to
return MI_FAILURE
every time it is called.
The smfi_chgheader
() routine may be called
only from within the xxfi_eom
() function you write (Milter xxfi_eom()
on page 1215). It is called like this:
ret
= smfi_chgheader(ctx
,name
,index
,value
);
Here, ctx
is the common
context pointer that was passed to your xxfi_eom
() function.
The name
is the name of
the header whose value you wish to change, and
value
is the new value
you wish to assign to that header. On success,
MI_SUCCESS
will
be returned (to ret
) or
MI_FAILURE
will
be returned if anything went wrong.
If value
is set to NULL
, the header will be
removed.
The index
is a count (not
an offset) and must be greater than zero. The
index
should normally
be set to one in order to change the value of the
first occurrence of a header with the
name
. Some header names can appear multiple times, however (the ...
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.