Blame | Letzte Änderung | Log anzeigen | RSS feed
<?php/*** @package Content-management* @author Lars Tiefland <tiefland@weban.de>* @copyright 2009 Webagentur Niewerth* @license propietary http://www.weban.de* @version $Rev$* @filesource**//**** @package Content-management* @author Lars Tiefland <tiefland@weban.de>* @copyright 2009 Webagentur Niewerth*/// SVN: $Id: functions.common.php 51 2009-10-07 09:43:24Z tiefland $/*** Demonstrates how to set-up a basic inbox using Mail_IMAP.* 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***/error_reporting( E_ALL );require_once 'Mail/IMAP.php';// 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$connection = 'imap://'.urlencode("rs@mediaran.de").':EW-ad-1055@mail.mediaran.de:143/INBOX#notls';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 connectionif ( !$msg->connect($connection) ){echo $msg->alerts();echo $msg->errors();echo"<SPAN style='font-weight: bold;'>Error:</SPAN> Unable to build a connection.";}// Unread messages appear with LIGHTGRAY links// Read messages appear with WHITE links// If you are using an IMAP-protocol based mail server,// POP3 doesn't remember flag settings// Retrieve message count$msgcount = $msg->messageCount();echo "<TITLE> Mail_IMAP Inbox </TITLE><LINK rel='stylesheet' type='text/css' href='IMAP.css' media='all'><DIV id='header'><H1>PEAR :: Mail_IMAP</H1></DIV><DIV id='inboxbody'><DIV id='msgcount'>{$msg->mailboxInfo['folder']}: ($msgcount) messages total.</DIV><TABLE class='msg'><THEAD><TR><TH>subject</TH><TH>from</TH><TH>received</TH></TR></THEAD><TBODY>\n";if ( $msgcount > 0 ){/** Each message of a mailbox is numbered offset from 1* Create the $mid (message id) and recursively gather* message information.*/for ( $mid = 1; $mid <= $msgcount; $mid++ ){// Get the headers$msg->getHeaders( $mid );$style = ( (isset($msg->header[$mid]['Recent']) && $msg->header[$mid]['Recent'] =='N') || (isset($msg->header[$mid]['Unseen']) && $msg->header[$mid]['Unseen'] == 'U') ) ? 'gray' : 'black';// Grab inline and attachment parts relevant to top level parts.// See the docs for the $msg property for more information:// http://www.smilingsouls.net/index.php?content=Mail_IMAP/msg$msg->getParts( $mid );if ( !isset($msg->header[$mid]['subject']) || empty($msg->header[$mid]['subject']) ){$msg->header[$mid]['subject'] ="<SPAN style='font-style: italic;'>no subject provided";}echo " <TR>\n"," <TD class='msgitem'><A href='IMAP.message_viewer.php?mid={$mid}&pid=" .$msg->msg[$mid]['pid'] . "' target='_blank' style='color: {$style};'>" .$msg->header[$mid]['subject'] . "</A></TD>\n"," <TD class='msgitem'>\n"," ", ( isset($msg->header[$mid]['from_personal'][0]) &&!empty($msg->header[$mid]['from_personal'][0]) ) ?'<SPAN title="' . str_replace( '@', ' at ', $msg->header[$mid]['from'][0] ) .'">' . $msg->header[$mid]['from_personal'][0] . "</SPAN>" :str_replace( '@', ' at ', $msg->header[$mid]['from'][0] ), "\n"," </TD>\n"," <TD class='msgitem'>" . date( 'D d M, Y h:i:s',$msg->header[$mid]['udate'] ) . "</TD>\n"," </TR>\n"," <TR>\n"," <TD colspan='3' class='msgattach'>\n";// Show inline parts firstif ( isset($msg->msg[$mid]['in']['pid']) && count($msg->msg[$mid]['in']['pid']) >0 ){foreach ( $msg->msg[$mid]['in']['pid'] as $i => $inid ){$fname = ( isset($msg->msg[$mid]['in']['fname'][$i]) ) ?$msg->msg[$mid]['in']['fname'][$i] : null;echo" Inline part: <A href='IMAP.message_viewer.php?mid={$mid}&pid=" .$msg->msg[$mid]['in']['pid'][$i] ."' target='_blank'>" . $fname . " " . $msg->msg[$mid]['in']['ftype'][$i] ." " . $msg->convertBytes( $msg->msg[$mid]['in']['fsize'][$i] ) ."</A><BR>\n";}}// Now the attachmentsif ( isset($msg->msg[$mid]['at']['pid']) && count($msg->msg[$mid]['at']['pid']) >0 ){foreach ( $msg->msg[$mid]['at']['pid'] as $i => $aid ){$fname = ( isset($msg->msg[$mid]['at']['fname'][$i]) ) ?$msg->msg[$mid]['at']['fname'][$i] : null;echo" Attachment: <A href='IMAP . message_viewer . php ? mid ={$mid}&pid = " .$msg->msg[$mid]['at']['pid'][$i]."' target='_blank'>".$fname." ".$msg->msg[$mid]['at']['ftype'][$i]." ".$msg->convertBytes($msg->msg[$mid]['at']['fsize'][$i])."</A><BR>\n";}}echo " </TD>\n"," </TR>\n";// Clean up left over variables// $msg->unsetParts($mid);// $msg->unsetHeaders($mid);}}else{echo " <TR>\n"." <TD colspan='3' style='font-size: 30pt; text-align: center; padding: 50px 0;'>No Messages</TD>"." </TR>\n";}echo " </TBODY>\n"." </TABLE>\n"." <DIV id='quota'>\n"." mailbox: {$msg->mailboxInfo['user']}<BR>\n";// getQuota doesn't work for some servers if ( $quota = $msg->getQuota() ){echo " Quota: {$quota['STORAGE']['usage']} used of {$quota['STORAGE']['limit']} total\n";}echo " </DIV>\n" ." </DIV>\n" . " <DIV id='footer'>\n" . " <P>\n" ." © Copyright 2004 Richard York, All Rights Reserved.<BR>\n" ." Best viewed with <A href='http ://www.mozilla.org'>Mozilla</A> and other standards-based browsers. Visit the <A href='http://www.smilingsouls.net'>Mail_IMAP</A> homepage.\n"." </P>\n" . " </DIV>\n" ." \n" . " ";// Close the stream$msg->close();// View errors gathered by PEAR_ErrorStack// Uncommment to see more errors.// if ($msg->error->hasErrors()) {// echo "<PRE style="display: block; white-space: pre;">\n";// var_dump($msg->error->getErrors());// echo "</PRE>\n";// }?>