Next: Body Modification Functions, Previous: Envelope modification functions, Up: Library [Contents][Index]
There are two ways to modify message headers in a MFL script. First is to use header actions, described in Actions, and the second way is to use message modification functions. Compared with the actions, the functions offer a series of advantages. For example, using functions you can construct the name of the header to operate upon (e.g. by concatenating several arguments), something which is impossible when using actions. Moreover, apart from three basic operations (add, modify and remove), as supported by header actions, header functions allow to insert a new header into a particular place.
Adds a header ‘name: value’ to the message.
In contrast to the add
action, this function allows to construct
the header name using arbitrary MFL expressions.
This syntax is preserved for backward compatibility. It is equivalent
to header_insert
, which see.
This function inserts a header ‘name: ‘value’’ at
idxth header position in the internal list of headers maintained
by the MTA. That list contains headers added to the message either by
the filter or by the MTA itself, but not the headers included in the
message itself. Some of the headers in this list are conditional,
e.g. the ones added by the ‘H?cond?’ directive in
sendmail.cf. MTA evaluates them after all header modifications
have been done and removes those of headers for which they yield false.
This means that the position at which the header added by
header_insert
will appear in the final message will differ from
idx.
Delete header name from the envelope. If index is given, delete indexth instance of the header name.
Notice the differences between this function and the delete
action:
delete
requires it to be a literal string.
Replace the value of the header name with value. If index is given, replace indexth instance of header name.
Notice the differences between this function and the replace
action:
replace
requires it to be a literal string.
Defined in the module header_rename.mfl.
Available only in the ‘eom’ handler.
Renames the idxth instance of header name to newname. If idx is not given, assumes 1.
If the specified header or the idx instance of it is not present in the current message, the function silently returns. All other errors cause run-time exception.
The position of the renamed header in the header list is not preserved.
The example below renames ‘Subject’ header to ‘X-Old-Subject’:
require 'header_rename' prog eom do header_rename("Subject", "X-Old-Subject") done
Defined in the module header_rename.mfl.
Available only in the ‘eom’ handler.
Renames all headers named name by prefixing them with prefix. If prefix is not supplied, removes all such headers.
All renamed headers will be placed in a continuous block in the header list. The absolute position in the header list will change. Relative ordering of renamed headers will be preserved.
Defined in the module header_rename.mfl.
Available only in the ‘eom’ handler.
Renames all headers with names matching pattern (in the sense of
fnmatch
, see fnmatches) by prefixing
them with prefix.
All renamed headers will be placed in a continuous block in the header list. The absolute position in the header list will change. Relative ordering of renamed headers will be preserved.
If called with one argument, removes all headers matching pattern.
For example, to prefix all headers beginning with ‘X-Spamd-’ with an additional ‘X-’:
require 'header_rename' prog eom do header_prefix_pattern("X-Spamd-*", "X-") done
Next: Body Modification Functions, Previous: Envelope modification functions, Up: Library [Contents][Index]