PHP Classes

File: example.php

Recommend this page to a friend!
  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: 7 years ago
Size: 1,136 bytes


Class file image Download
require_once(dirname(__FILE__) . '/MailParser.php');

// Creating mail parser class object with mailbox, username and password parameters
$obj = new MailParser("{}", '', 'mypassword');

// Parsing messages by different filter
$obj->pasrseMessagesByFromAddress('', true);
$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'];


//This code is used when user wants to save attachements locally
    // If attachements have same name then it will override.
if($attachments) {
$attachments as $fileName => $data) {
$fh = fopen($fileName, 'wb');
fwrite($fh, $data);