[cvs] [Wiki] changed: MIMEHowTo

Jan Schneider jan at horde.org
Tue Mar 8 00:54:13 PST 2005


jan  Tue,  8 Mar 2005 00:54:13 -0800

Modified page: http://wiki.horde.org/display.php?page=MIMEHowTo
New Revision:  2.0

@@ -1,5 +1,7 @@
 + How to use the MIME API
+
+[[toc]]
 
 ++ Creating MIME messages
 
 Scenario: 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.
@@ -57,4 +59,29 @@
 require_once 'Horde/MIME/Viewer.php';
 $viewer = &MIME_Viewer::factory($part);
 $html = $viewer->render();
 </code>
+
+++ Reading message headers
+
+Scenario: We want to read a certain message from a certain message on the mail server, for example to search for messages with a known header.
+
+<code type="php">
+/* Load libraries. */
+require_once 'Horde/MIME/Headers.php';
+require_once 'Horde/NLS.php';
+
+/* Custom MIME_Headers class because we need to implement _getStream(). */
+class MyHeaders extends MIME_Headers {
+
+    function &_getStream()
+    {
+        return imap_open('{localhost/imap}INBOX', 'username', 'password');
+    }
+}
+
+/* Get message subject. */
+$headers = &new MyHeaders($message_uid);
+$headers->buildHeaders();
+$subject = $headers->getValue('Subject');
+</code>
+


More information about the cvs mailing list