Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ashish Kumar  >  Mail Parser  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: How to use MailParser class
Class: Mail Parser
Retrieve and parse messages from IMAP mail boxes
Author: By
Last change: Changed for dummy data
Date: 2009-08-21 06:22
Size: 1,136 bytes
 

Contents

Class file image Download
<?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}"'xyz.abc@gmail.com''mypassword');

// Parsing messages by different filter
$obj->pasrseMessagesByRecDate('08-20-2009');
/*
$obj->pasrseMessagesByFromAddress('abc.xyz@gmail.com', 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);
        }
    }
}

?>