NAME

Mail::DKIM2::Wrap - wrap a single-part message in a one-part multipart/mixed

SYNOPSIS

use Mail::DKIM2::Wrap qw(wrap_single_part);
my $w = wrap_single_part($message) or return;   # undef: already multipart
# $w->{message}, $w->{body}, $w->{boundary}, $w->{edits}

DESCRIPTION

A list manager that adds a footer to a single-part text/plain post re-encodes the whole body, and the change can then only be described by a null body Recipe. Wrapping the post first -- its Content-* fields and its body, byte for byte, become the only part of a multipart/mixed -- makes the footer an extra part instead. dkim2-milter --wrap-single-part applies this at ingress for stock Mailman.

FUNCTIONS

wrap_single_part($message, %options)

$message is a whole message with CRLF line ends. Returns undef when it wraps nothing -- in list context (undef, $reason), the reason being multipart (already multipart/*, the normal case), no-header-end (no blank line after the header), unparsable-header (a header line that is not a field), or boundary (no boundary clear of the body) -- else a hash reference: message (the wrapped message), body (its new body), boundary, and edits, the header changes as milter operations: deletes (name, 1-based index among fields of that name, last first), then the change of the first Content-Type, then additions (Content-Type if there was none, MIME-Version: 1.0 if absent). Option Boundary is a code reference returning a candidate boundary; the default is random. A candidate that occurs in the body is skipped.