| 
<?php
require_once(dirname(__FILE__) . '/MailParser.php');
 
 // Creating mail parser class object with mailbox, username and password parameters
 $obj = new MailParser("{imap.gmail.com:993/imap/ssl}", '[email protected]', 'mypassword');
 
 // Parsing messages by different filter
 $obj->pasrseMessagesByRecDate('08-20-2009');
 /*
 $obj->pasrseMessagesByFromAddress('[email protected]', true);
 $obj->pasrseMessagesBySubject('test4');
 $obj->pasrseUnreadMessages();
 $obj->pasrseMessageById(4, true);
 */
 
 // Getting result
 $result = $obj->getResult();
 
 // Retrieving the message information from $result
 foreach($result as $msg) {
 
 $palinText        = $msg['plainBody'];
 $html            = $msg['htmlBody'];
 $header            = $msg['headers'];
 $attachments    = $msg['attachments'];
 
 //print_r($palinText);
 //print_r($html);
 print_r($header);
 
 //This code is used when user wants to save attachements locally
 // If attachements have same name then it will override.
 if($attachments) {
 foreach($attachments as $fileName => $data) {
 $fh = fopen($fileName, 'wb');
 fwrite($fh, $data);
 fclose($fh);
 }
 }
 }
 
 ?>
 |