[Mimedefang] MIME::Entity->attach encoding of an already encoded body/bodyhandle

Rolf E. Sonneveld R.E.Sonneveld at sonnection.nl
Thu Aug 4 10:20:48 EDT 2011


Hi,

during the 'filter' phase I store a reference to one of the bodyparts of 
the incoming message (this bodypart is base64 encoded at this stage), using:

$bodypart = $entity->body

Next, I try to use this bodypart during the 'filter_end' phase to create 
a new MIME entity ($newmsg). I try to attach this bodypart using:

$newmsg->attach(Data => $bodypart,
    Encoding => "base64");

or

$newmsg->attach(Data => $bodypart,
    Encoding => "-SUGGEST");

the result is that MIMEDefang (or MIME::Entity) encodes the already 
encoded base64 blob again using base64, which effectively creates a 
bodypart that cannot be used by the recipient.

When I use

$newmsg->attach(Data => $bodypart,
    Encoding => "7bit");

the MIME encoded bodypart is not encoded again, however, this leaves me 
with the wrong bodypart Content-transfer-encoding label (7bit).
When fetching the $bodypart using $entity->bodyhandle (which seems 
exactly what I need), I get the following error in syslog when 
submitting a message:

Slave 1 stderr: I can't handle DATA which is a MIME::Body::File

I may be able, probably, to work around this by first dumping the 
(decoded) contents to a tmpfile, then attach it using base64 (which 
encodes the bodypart again) but that's not very efficient.

What is the recommended approach here?

/rolf



More information about the MIMEDefang mailing list