I'm running into a related issue with a plugin that strips attachments
from email (using MIME::Parser) and makes them available for download.
The relevant snippet of the source:
my $email = $parser->parse_open($transaction->body_filename);
$email = strip_attachments($email, $root_url);
open FILE, '>', $transaction->body_filename
or die "Couldn't open temporary message body: $!\n";
$email->print(\*FILE)
or die "Couldn't write temporary message body: $!\n";
close FILE
or die "Couldn't close temporary message body: $!\n";
As it is, I would have to update $email->head with the headers
according to $transaction->header before stripping the attachments,
and update $transaction->header with the new headers (i.e. those in
$email->head after stripping).
Besides this, I would have to write the old headers followed by the
new body to disk, so Qpsmtpd::Transaction->{_header_size} (and
_body_start) stays in sync.
Is there a better way?
Arien