Corrupted MIME headers of messages in Sent folder
|Reported by:||Javer||Owned by:|
I have created new message in html format, add attachment and send mail. Message was constructed correctly and sent, but then I see in Sent folder corrupted message, which source looks like this:
Content-Type: multipart/mixed; boundary="=_af390738b330610b94ac7493098a53b2"; boundary="=_1fb986a9e9fa3f26e349f7535a85926e" --=_1fb986a9e9fa3f26e349f7535a85926e Content-Type: multipart/alternative; boundary="=_9daf87b9cced08d52c0d02aeb0a2ab1a" --=_9daf87b9cced08d52c0d02aeb0a2ab1a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit
There are duplicate boundary for multipart/mixed MIME-part. This is because process of sending mail flows in following order:
$MAIL_MIME = new rcube_mail_mime(rcmail_header_delm()); ... $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto); |-> ... $msg_body = $message->get(); ... ... $saved = $IMAP->save_message($CONFIG[$store_target], $MAIL_MIME->getMessage()); |-> ... $body = $this->get($build_params); ...
We have duplicate call of get() method of Mail_mime class. And because each call of this method interprets separated html, plain, images, attachments parts and builds final MIME message, it add every time new multipart/mixed part around previously built message, and we have duplicate boundary and corrupted headers. This results in empty body while viewing message in Sent folder.
Patch provides caching of body of constructed MIME Message to avoid duplicate construction of message and damage of MIME headers.