Yii 1.1: eimap

EIMap - Easy access to your imap inbox
26 followers

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

Total 13 comments

#17901 report it
pannet1 at 2014/08/08 11:19am
POP support

I read elsewhere in YII forum, that imap-php supports POP also. Any way to support POP also.

#17388 report it
Rohit Suthar at 2014/06/02 08:11am
To connect to POP3 server with a self-signed certificate

For eg. gmail account -

$imap = new EIMap('{pop.gmail.com:995/pop3/ssl/novalidate-cert}INBOX', 'yourusername', 'yourpassword');

for more help check here

#16801 report it
CristianM at 2014/03/29 05:24pm
MIME type proble

Hi everyone,

I've been working with this ext for a while, but I notice something: it seems that when an mail got a "text/plain" attachment (.txt, .cpp, .php, etc.) my app don't show it and in the wierd case that the email appears in the app, then the "text/plain" attachment is shown down as if it was part of the mail, for example:


Hi this is an email,

etc etc etc.....

The Email ends here.

int main(){return 0;}

(and here is the attachemnt to be downloaded) main.cpp

I've been trying to solve this problem but with no success if anyone can help me I'll be really greatful

#15480 report it
code4d1 at 2013/11/14 02:37am
server path

to make it work I use this server path :

$imap = new EIMap('{mydomain.com:995/pop3/ssl/novalidate-cert}INBOX', .. .....
#15466 report it
ddsultan at 2013/11/13 05:41am
How to get attached file's name

Hi friends

I have gotta problem using this extension while getting (extracting) attached file's name. Can anybody can? Would be great if found the way how to get file name through the extension.

#13520 report it
shiv at 2013/06/03 02:30pm
Thank you !

Its working . I glad that I found it . Thank you !

#11582 report it
ikary at 2013/01/21 06:20pm
bug

replace

if (($structure->ifdisposition && strtolower($part->disposition) == 'attachment' && $structure->ifdparameters) ||   (in_array(strtolower($part->subtype), $imgTypes))

by

if( property_exists($part, 'disposition') && strtolower($part->disposition)=='attachment')

if not, the code only worked when the attachments were images, a non sense, ifdisposition has nothing to do

.... modifying this extension to be usable, ....I'll upload the result

#11516 report it
ikary at 2013/01/18 04:00am
not work if php < 5.3.2

imap_open not work with 6 parameters if php<5.3.2, replace imap_open line, by this:

if (version_compare(PHP_VERSION, '5.3.2', '<') ) {
    $ev->stream = $this->stream = @imap_open($this->mailbox, $this->username, $this->password, $options, $retries);
}
else {
    $ev->stream = $this->stream = @imap_open($this->mailbox, $this->username, $this->password, $options, $retries,  $params);
}
#11398 report it
Ivo Renkema at 2013/01/11 03:33am
@dve, Nisanth thulasi

Good to hear. If there are any problems, please ask a question at Stackoverflow.

#11396 report it
dve at 2013/01/11 01:45am
thanks

Thans,it's working now.

#11379 report it
Nisanth thulasi at 2013/01/10 05:28am
bug for video attachment

HI Ivo Renkema

i changed my code with that you mentioned but not supporting any video formated file type

#10752 report it
dve at 2012/11/21 08:14am
Help

I try this extension but it 's not working for me .

I use this $imap = new EIMap('{imap.gmail.com:993/imap/ssl}INBOX', 'myemail@gmail.com', 'mypasswor')

but it's return blank page. I don't know why

I need help.

#10677 report it
Ivo Renkema at 2012/11/14 07:46am
bug for video attachments

Thanks for the extension!

It took me while to get it to work for video-file attachments.

First, I expanded $imgTypes to include 'mp4', et cetera. But even then the download of the attachment failed.

Secondly, I believe there is a bug in getAttachment(). The line:

    $data = $this->decodeValue($body, $part->type);

should actually be:

    $data = $this->decodeValue($body, $part->encoding);

Is that right? After the above changes, downloading video attachments seems to work.

Leave a comment

Please to leave your comment.

Create extension