Sieve editheader extension

From Messaging Server Technical Reference Wiki
Jump to: navigation, search

The MTA has supported the addheader action (prior to its standardization) since circa MS 6.1, and the standard deleteheader action and proposed replaceheader action since MS 6.3. The standard capability string in order to use an addheader or deleteheader action, as defined in RFC 5293 (Sieve Email Filtering: Editheader Extension), or a replaceheader action, as defined in draft-degener-sieve-editheader-00, is "editheader", although note that the MTA does not enforce this for the addheader action (addheader may be used without a "require" clause):

require "editheader";

The MTA has a configurable limit on how many addheader actions will be permitted in a single Sieve script, max_addheaders. The default is 10. As of the 8.0 release, this limit only applies to user-level Sieves.

When specifying a header label in an addheader action, note that the header label length is limited to 256 characters, and may not contain any eight bit characters (characters above ASCII position 126) nor control characters (characters below ASCII position 33) as well as not containing the colon character, :.

Note that it may often be useful to make use of the Sieve variables extension along with editheader, and perhaps especially in conjunction with the "replaceheader" action. This is illustrated in the following example in which a site's broken DMARC usage, which could break mailing lists for innocent other members of the list is ameliorated by forcibly modifying the (broken domain's) addresses so as not to trigger bounce messages for messages from this broken domain to other list recipients thereby causing the innocent list members to be removed from mailing lists.

require ["editheader","variables"];
if address :domain :is "From" "" {
# addresses that include phrase and/or comment:
 replaceheader :newvalue "${1}<${2}>>${3}"
         :matches "From" "*<*>*";
# Simple addresses:
 replaceheader :newvalue "${1}"
         :matches "From" "*"; 
 addprefix text:
Due to's broken use of DMARC, the From: address 
in this message has been replaced by <original-address>.invalid.

To reply to the original sender of this message, remove the .invalid
from the end of the domain.


See also: