eimap EIMap - Easy access to your imap inbox

Overview

The EIMap Class allows to have easy access to imap extension functions to read and parse messages from a mailbox.

Requirements
How to use

Extract and place the contents of the package into your extensions folder (you can place it where ever you wish, the extensions folder is for the sake of the example).

Examples

reading unseen emails

Yii::import('ext.EImap.EIMap', true);
	
// please replace the server path to the one of your
// inbox + your username and password
$imap = new EIMap('{imap.server.com:993}/imap/ssl}INBOX', 'yourusername', 'yourpassword');
	
if($imap->connect())
{
	// we are set lets search for unseen
	$unseen = $imap->searchmails( EIMap::SEARCH_UNSEEN );
		
	if($unseen && is_array($unseen)) // do we have any?
	{
		// put new ones first
		rsort($unseen);
			
		foreach($unseen as $msgId)
		{
			$mail = $imap->getMail( $msgId );
			echo '<pre>'.( CVarDumper::dumpAsString( $mail ) ).'</pre>';
		}
	}
	$imap->close(); // close connection		
}

reading mails overviews

Yii::import('ext.EImap.EIMap', true);
	
// please replace the server path to the one of your
// inbox + your username and password
$imap = new EIMap('{imap.server.com:993}/imap/ssl}INBOX', 'yourusername', 'yourpassword');
	
if($imap->connect())
{
	// get mailbox info
	$mailboxCheck = $imap->getCheck();
	
	// read all messages overviews
	$result = $imap->getMailboxOverview("1:{$mailboxCheck->Nmsgs}");

	// if we have any display them
	foreach($result as $overview)
	{
		echo "#{$overview->msgno} ({$overview->date}) - From: {$overview->from} {$overview->subject}\n";
		echo "size: {$overview->size}";
		echo '<pre>'.CVarDumper::dumpAsString($overview).'</pre>';
		
		// sender again please?
		echo '<pre>'.CVarDumper::dumpAsString($imap->getSender($overview->msgno)).'</pre>';
	}
	$imap->close(); // close connection		
}

====

Clevertech
well-built beautifully designed web applications
www.clevertech.biz

8 0
29 followers
1 542 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Mail
Tags: email, imap
Developed by: Antonio Ramirez
Created on: Aug 29, 2012
Last updated: 12 years ago

Downloads

show all

Related Extensions