Richard York

Web Developer, Author, and Artist

Mail_IMAPv2 Part Viewer Example

<?php /** * This example provides a basic demonstration of how Mail_IMAP can be used to * view multipart messages. See {@link connect} for extended documentation on * how to set the connection URI. * * @author Richard York <rich_y@php.net> * @copyright (c) Copyright 2004, Richard York, All Rights Reserved. * @package Mail_IMAP * @subpackage examples ** */ // Use an existing imap resource stream, or provide a URI abstraction. // Example of URI: // pop3://user:pass@mail.example.com:110/INBOX#notls // // If you are unsure of the URI syntax to use here, // use the Mail_IMAP_connection_wizard to find the right URI. // Or see docs for Mail_IMAP::connect // // The connection URI must also be set in: // IMAP.inbox.php. // IMAP.message_viewer.php // IMAP.part_viewer.php require_once '../IMAP.php'; $connection = 'imap://user:pass@mail.example.net:143/INBOX'; if (!isset($_GET['dump_mid'])) { $msg =& new Mail_IMAP(); } else { // Call on debuging automatically. include 'Mail/IMAP/Debug/Debug.php'; $msg =& new Mail_IMAP_Debug($connection); if ($msg->error->hasErrors()) { $msg->dump($msg->error->getErrors(TRUE)); } } // Open up a mail connection if (!$msg->connect($connection)) { echo $msg->alerts(); echo $msg->errors(); echo "<span style='font-weight: bold;'>Error:</span> Unable to build a connection."; } $body = $msg->getBody($_GET['mid'], $_GET['pid']); // Use this to *not* set the seen flag // $body = $msg->getBody($mid, $pid, 0, 'text/html', FT_PEEK); // // Must also use this in the call to getHeaders above. header('Content-Type: '.$body['ftype']); echo $body['message']; // Close the stream $msg->close(); ?>

Comments

There are no comments posted at this time.

Leave a Comment

Simple HTML is allowed: <code>, <b>, <i>, <u>, <var>, <strong>, <em>, <blockquote>, <ul>, <ol>, <li>, <p> (no attributes). All spacing and line breaks in your comment will be preserved.

* All comments are moderated and are subject to approval.
Your comment will appear once it has been approved.
Posting multiple times will not expedite the approval process.

Comments are closed at this time.

© Copyright 2014 Hot Toddy, All Rights Reserved.