[dev] MIME handling

Michael M Slusarz slusarz at mail.curecanti.org
Tue Sep 21 08:52:13 PDT 2004


Quoting StuartBingë <omicron-list at mighty.co.za>:

> Hi guys,
>
> Just a question about what the proper way to handle MIME messages using the
> Horde MIME libraries is.
>
> Here's the problem I'm facing: I've got a text representation of an email
> message, and need to get a (properly decoded) text representation of a
> particular MIME part (that has a specific MIME type). Here's a paraphrased
> version of how I'm currently doing it:

I'm assuming that you are only looking for the first MIME part that 
matches the
specific MIME type.  If so, what you have is correct.  I would make the
following optimization though:

$mime_message = &MIME_Structure::parseTextMIMEMessage($text_message);
$mime_parts = $mime_message->contentTypeMap();
if (($mime_id = array_search($desired_content_type, $mime_parts)) !== false) {
     $mime_part = $mime_message->getPart($mime_id);
     $desired_text = $mime_part->transferDecode();
}

transferDecode() does all the conversion between q-p/base 64 to 7bit/8bit for
you, which is most likely what you need to work with locally.

michael

_______________________________________
Michael Slusarz [slusarz at curecanti.org]


More information about the dev mailing list