[dev] kolab::getMessageHeaders warnings

Michael M Slusarz slusarz at bigworm.colorado.edu
Tue Mar 30 10:22:19 PST 2004


Quoting Stuart Bingë <s.binge at codefusion.co.za>:

> On Tuesday 30 March 2004 15:04, Jan Schneider wrote:
>> Why don't you use Horde's MIME classes?
>
> Well it would have to be because of documentation :-)
> The PEAR stuff had sample code to do exactly what we needed to do, which made
> it really quick to implement - unfortunately we didn't have the time to look
> at the Horde classes as an alternative.
>
> If you (or someone else who is familiar with the Horde MIME classes) could
> describe how we can do what needs doing using the Horde MIME libraries then
> I'd have no problems converting. We basically have two scenarios:
>
> 1. We have a text block (such as text/calendar data) which needs to be added
> as a MIME part to an email message. We then need to add a couple of
> additional headers to this message and finally read it back as a string.

For Message Body:
$message = &new MIME_Message();
$part = $new MIME_Part('text/calendar', $text_calendar_data);
$message->addPart($part);

For Headers:
$headers = &new MIME_Headers();
$headers->addHeaders('Header 1', $Header_1_Value);
$headers->addHeaders('Header 2', $Header_2_Value);
$headers->addMIMEHeaders($message);

To return the message as a string:
$string = $headers->toString() . "\n\n" . $part->toString();

> 2. We have an existing text string which contains a valid MIME email message.
> We need to parse this string in order to read back the body of a specific
> MIME part with a certain content type.

$message = &MIME_Structure::parseTextMIMEMessage($message_text);
$message->getPart($mime_id);
   -OR-
$map = $message->contentTypeMap();
   Map is an array with KEY = MIME ID and VALUE = Content type of that ID

michael

______________________________________________
Michael Slusarz [slusarz at bigworm.colorado.edu]
The University of Colorado at Boulder


More information about the dev mailing list