I have several Zend_Mail_Message
objects that I got from an IMAP query.
Now I want to serialize each message individually.
However, it seems that a simple:
serialize($message);
doesn't work because the message has attachments (multipart), and the parts don't get serialized.
So, how to serialize a complete Zend_Mail_Message
object, including parts (attachements)?
I figured it out. Basically Zend_Mail_Message has cache mechanism, so when you get a part from the message it doesn't ask the IMAP server again for that part.
So the key was to warm up the cache before serializing:
$i=0;
while ($part = $message->getPart($i) {
$i++;
}
$serialization=serialize($message); //now it saves the whole message.