CSS: Providing seven essential vitamins and minerals since 1996.
Have a steaming hot, delicious slice of Standards.

Mail_IMAPv2 Message Viewer Example

* @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 'Mail/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 "Error: Unable to build a connection."; } // Get parts and headers $mid = $_GET['mid']; $pid = $_GET['pid']; $msg->getParts($mid, $pid); $msg->getHeaders($mid, $pid); function Mail_IMAP_do_address_line(&$msg, &$mid, $line) { $rtn = (string) ''; if (!empty($msg->header[$mid][$line])) { foreach ($msg->header[$mid][$line] as $i => $address) { if (isset($msg->header[$mid][$line.'_personal'][$i]) && !empty($msg->header[$mid][$line.'_personal'][$i])) { $rtn .= "header[$mid][$line][$i])."'>".$msg->header[$mid][$line.'_personal'][$i]." ;\n"; } else { $rtn .= str_replace('@', ' at ', $msg->header[$mid][$line][$i])."; \n"; } } } return $rtn; } function Mail_IMAP_do_parts(&$msg, &$mid, $disp) { $rtn = (string) ''; if (isset($msg->msg[$mid][$disp]['pid']) && count($msg->msg[$mid][$disp]['pid']) > 0) { foreach ($msg->msg[$mid][$disp]['pid'] as $i => $inid) { $rtn .= "msg[$mid][$disp]['pid'][$i]."' target='top'>".$msg->msg[$mid][$disp]['fname'][$i]." ".$msg->msg[$mid][$disp]['ftype'][$i]." ".$msg->convertBytes($msg->msg[$mid][$disp]['fsize'][$i])."
\n"; } } return $rtn; } echo " Mail_IMAP Inbox
Subject: {$msg->header[$mid]['subject']}
To: \n".Mail_IMAP_do_address_line($msg, $mid, 'to')."
Cc: \n".Mail_IMAP_do_address_line($msg, $mid, 'cc')."
From: \n".Mail_IMAP_do_address_line($msg, $mid, 'from')."
Received: ".date('D d M, Y h:i:s', $msg->header[$mid]['udate'])."
Inline Parts: ".Mail_IMAP_do_parts($msg, $mid, 'in')."
Attachments: ".Mail_IMAP_do_parts($msg, $mid, 'at')."
"; ?>
PHP Powered XHTML 1.0 CSS
Copyright © 1998-2010 Richard York, All Rights Reserved.