Retrieve Your Gmail Emails Using PHP and IMAP
»Grabbing emails from your Gmail account using PHP is probably easier than you think. Armed with PHP and its IMAP extension, you can retrieve emails from your Gmail account in no time! Just for fun, I'll be using the MooTools Fx.Accordion plugin to display each email.
The CSS
div.toggler { border:1px solid #ccc; background:url(gmail2.jpg) 10px 12px #eee no-repeat; cursor:pointer; padding:10px 32px; }
div.toggler .subject { font-weight:bold; }
div.read { color:#666; }
div.toggler .from, div.toggler .date { font-style:italic; font-size:11px; }
div.body { padding:10px 20px; }
Some simple CSS formatting.
The MooTools JavaScript
window.addEvent('domready',function() {
var togglers = $$('div.toggler');
if(togglers.length) var gmail = new Fx.Accordion(togglers,$$('div.body'));
togglers.addEvent('click',function() { this.addClass('read').removeClass('unread'); });
togglers[0].fireEvent('click'); //first one starts out read
});
Some simple accordion code.
The PHP
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'davidwalshblog@gmail.com';
$password = 'davidwalsh';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inbox,'ALL');
/* if emails are returned, cycle through each... */
if($emails) {
/* begin output var */
$output = '';
/* put the newest emails on top */
rsort($emails);
/* for every email... */
foreach($emails as $email_number) {
/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_fetchbody($inbox,$email_number,2);
/* output the email header information */
$output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
$output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
$output.= '<span class="from">'.$overview[0]->from.'</span>';
$output.= '<span class="date">on '.$overview[0]->date.'</span>';
$output.= '</div>';
/* output the email body */
$output.= '<div class="body">'.$message.'</div>';
}
echo $output;
}
/* close the connection */
imap_close($inbox);
With our individual username/password settings set, we connect to Gmail. Once connected, we request all emails. If we find emails, I reverse sort the emails so that the newest emails appear on top. For every email we receive, I output the subject and message in MooTools Fx.Accordion format.
Now that I've shown you the basics, it's time for you to build your next great PHP email app! Go ahead and send a few emails to davidwalshblog@gmail.com to see your eamil display on the page!
There are some encoding issues and I've not found a great way to include images. Any tips appreciated!
Discussion
Be Heard!
Share your thoughts with fellow developers of all skill levels! I want to hear from you!
great and useful many thanks David!
nice shot Dave!
I love it. Wish I could mark emails as read when you toggle them though.
Oh, and I noticed a flicker when toggling “unread” emails.
NVM the flicker thing, guess it was my FF acting weird :P
Your picture is outdated…gmail is out of beta ;)
I did that on purpose. Always beta!
O
how can one get a list of contacts of a gmail account? Facebook and most social networking sites do that…but how?
Awesome post. Can we do it for other emails ie Yahoo, Hotmail etc.
wow this is great code. Congratulations…
how to display new mails only?
@scvinodkumar – The method imap_fetch_overview() returns an array, one parameter of which is called ‘seen’. This flag indicates whether the message has been read or not. Likewise you have ‘answered’, whether you’ve replied to the message.
Good post David, thank you.
@Devang Paliwal: Absolutely! You’d need to get each service’s IMAP information though.
Is it secure? Could this be implemented with accounts contain personal and confidential mails?
@Zues: How you use this is up to you. I don’t recommend making your primary email account public.
Hmmm okay. But this is something great. Can brainstorm and come up with new and cool ideas :)
Can someone help ?
@soso: please enable “extension=php_imap.dll” in php.ini
I want get attachment de Gmail. How? Thanks.
Hey this looks awesome!
I tried to use it with wamp and am getting this error…any ideas? Thanks a lot for any help!!
Warning: imap_open() [function.imap-open]: Couldn’t open stream {imap.gmail.com:993/imap/ssl}INBOX in C:\wamp\www\email\howdy.php on line 13
Cannot connect to Gmail: Can’t open mailbox {imap.gmail.com:993/imap/ssl}INBOX: invalid remote specification
@chris: Not sure, could be an outbound connection or firewall issue. “Localhost” always bring trouble.
Thanks David, you were correct it was a firewall issue that blocked 993.
is this works for inline attachments such as picture added inside the text through outlook express?
Great stuff!
Q? Why I get this error : Cannot connect to Gmail: Can’t open mailbox {imap.gmail.com:993/imap/ssl}INBOX: invalid remote specification
@Iván: I had this same error, it’s your firewall settings blocking 993 port. When you unblock it, it works.
I´ve fixed my problem.
Thank You Chris.
Thank you so much you are genius!!!
great idea,
demo is down though, “Cannot connect to Gmail: Too many login failures”
@nimz: Ah, a Chelsea boy. Nice. Since I posted the article the accounts been hacked at. I’ll see if I can restore it.
Cannot connect to Gmail: Can’t open mailbox {imap.gmail.com:993/imap/ssl}INBOX: invalid remote specification – this error i get, when i run this code in localhost means local system..
dude.. awesome job.. but im unsing latin characters and i got ugly formed emails.. there is any parameter for change the charset?
This doesn’t work for me for some reason. I’m running it locally on Wamp, and I turned the firewall off… I can get the email subjects but when I click on them they don’t do anything.
maybe Im missing something but I could not find a download link to download this amazing script.
I downloaded the mootools.js file into a dir on my cpanel server. Then created a new file and think I put the above codes into the right place etc but when i try to load the page,it just sits there saying loading in the status bar, nothing happens, been waiting 9 minutes without error message.
any ideas please or am i missing a download link to download all files needed.
cheers
Dextor
Dextor: All of the necessary code is here. I’m guessing that your machine is having a problem connecting to GMail, or GMail is slow. The fact that it tries for a while instead of just dying means it’s attempting to get to Gmail. You may also want to change your username and password.
wow quick response, thanks David, can i pastbin my file so you can see if i have it setup right?
here is the pastebin.ca link
http://pastebin.ca/1570904
@Dextor: You need to make your code a complete page with,, etc. I also don’t see you bringing in the MooTools library.
This look better?
dreamweaver code color says the css / mootools part looks odd / wrong color like the syntax is out of place / incorrect
http://pastebin.ca/1570922
I get this error….
Cannot connect to imap: Certificate failure for imap.gmail.com: unable to get local issuer certificate: /C=US/O=Google Inc/CN=Google Internet Authority
How to solve the encoding problem’s???
Thank’s if you have an answer!
I get a bunch of garbage that looks like a SSL certificate after the first message and the body does not print on remaining emails. Any ideas?
–1248921015.4E4FF544.18054 Date: Wed, 29 Jul 2009 19:30:15 -0700 MIME-Version: 1.0 Content-Type: image/gif Content-Transfer-Encoding: base64 Content-Disposition: inline; filename=”email-vox-logo.gif” Content-ID: R0lGODlhawAtAOYAANcZIP////fR0v/8/Od1edgeJdopMPO7vd05P/309f739/GusONdYtccI/nf 4P76+uqFidkkKvzv79ghKPrk5dw0OvK2uNknLfjW2N9HTd5CR/fU1dsxOOd4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IE2VWMu23kABMaoH0ZVJGAfIIgdAGxAALwNQgFW UGIpfnCC8g3CBTHQAbfQU4Ie3EsRD6CBCiAJAA0MQYqCqIERbmiKAoQghZ9cxCGAuIRPGCIKXRnZ JTywzBwcAh8kEAAOlJKtSAxRCjMQQF0qEggAOw== –1248921015.4E4FF544.18054 Date: Wed, 29 Jul 2009 19:30:15 -0700 MIME-Version: 1.0 Content-Type: image/gif Content-Transfer-Encoding: base64 Content-Disposition: inline; filename=”spacer.gif” Content-ID: R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw== –1248921015.4E4FF544.18054–
Bob Snider : If the email has an attachment you will see that. The code in this place is just an idea to make a better code. Check the Imap functions at php.net . I’m still working in this, the idea is good but not complete.
hi this is superb script…
but i got some errors
Warning: imap_open() [function.imap-open]: Couldn’t open stream {imap.gmail.com:993/imap/ssl}INBOX in /home/ospreyan/public_html/kushal/mail.php on line 8
Cannot connect to Gmail: Can’t connect to gmail-imap.l.google.com,993: Connection refused
can you help me in that
i used ur exact code. there is no error but half of the code is printed instead of the emails.
here is the code i took from u exactly. try to run it with ur username and password. does it run correct. change the username and password. thanks anybody.
<?
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'yourusername@gmail.com';
$password = 'yourpassword';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to
Gmail: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inbox,'ALL');
/* if emails are returned, cycle through each… */
if($emails) {
/* begin output var */
$output = '';
/* put the newest emails on top */
rsort($emails);
print_r($emails);
/* for every email… */
foreach($emails as $email_number) {
/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_fetchbody($inbox,$email_number,2);
/* output the email header information */
$output.= 'seen ? “read” : “unread”).’”>’;
$output.= ”.$overview[0]->subject.’ ‘;
$output.= ”.$overview[0]->from.”;
$output.= ‘on ‘.$overview[0]->date.”;
$output.= ”;
/* output the email body */
$output.= ”.$message.”;
}
echo $output;
}
/* close the connection */
imap_close($inbox);
?>
If you are getting a lot of weird characters in the message body (i.e. =0D or =0A) then you have to check the encoding with imap_fetchstructure() and then decode it properly. You only need to decode for Quoted-Printable and Base64, however. Here is my code for this:
$structure = imap_fetchstructure($mailbox, $uid, FT_UID);
if($structure->encoding == “3″){
$body = base64_decode(imap_fetchbody($mailbox, imap_msgno($mailbox, $uid), 1));
}
elseif($structure->encoding == “4″){
$body = imap_qprint(imap_fetchbody($mailbox, imap_msgno($mailbox, $uid), 1));
}else{
$body = imap_fetchbody($mailbox, imap_msgno($mailbox, $uid), 1);
}
Note that I use UIDs, so this will have to be changed for however you are doing it.
@deepak: Fatal error: Call to undefined function imap_open() in C:\wamp\www\swaticlass\imapp.php
Im geeting this errior could nyone solve it
Cery cool script !!! But I notice that is very very slow to load. Why ?
Hi dave, I tried your exact code, but the javascript didn’t work. I’m using firefox 3.0.14 – php5 – apache2. All the email body (the messages) are all listed before i have to click the email subject. Any suggestion?
This is my phpcode:
<?php
$formatcss = "
“;
echo $formatcss;
$javascript = ”
window.addEvent(‘domready’,function() {
var togglers = $$(‘div.toggler’);
if(togglers.length) var gmail = new Fx.Accordion(togglers,$$(‘div.body’));
togglers.addEvent(‘click’,function() { this.addClass(‘read’).removeClass(‘unread’); });
togglers[0].fireEvent(‘click’); //first one starts out read
});
“;
echo $javascript;
/* connect to gmail */
$hostname = ‘{imap.gmail.com:993/imap/ssl}INBOX’;
$username = ‘username@gmail.com’;
$password = ‘password’;
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die(‘Cannot connect to Gmail: ‘ . imap_last_error());
/* grab emails */
$emails = imap_search($inbox,’ALL’);
/* if emails are returned, cycle through each… */
if($emails) {
/* begin output var */
$output = ”;
/* put the newest emails on top */
rsort($emails);
/* for every email… */
foreach($emails as $email_number) {
/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_fetchbody($inbox,$email_number,2);
/* output the email header information */
$output.= ‘seen ? ‘read’ : ‘unread’).’”>’;
$output.= ”.$overview[0]->subject.’ ‘;
$output.= ”.$overview[0]->from.”;
$output.= ‘on ‘.$overview[0]->date.”;
$output.= ”;
/* output the email body */
$output.= ”.$message.”;
}
echo $output;
}
/* close the connection */
imap_close($inbox);
?>
thanks
hi,
I got this error..Call to undefined function imap_open()
I enabled “extension=php_imap.dll” in php.ini
stil I have the same problem
@chris: how to blocked the 993 port on win xp…i had been added the port on exception, but still not working…
thanks…!!
@David Walsh: one more…
i used wamp on my server with localhost,…
and the error is stil “couldn’t not open stream”…
my server spec is : php. 5.2 and apache 2
if i replaced the php_imap.dll with the new one from php.5.3..the error is “Call to undefined function imap_open()”..even the php_imap extension is still enable on php.ini..
can u explain how to setting the php.ini or the firewall setup…please mail me…ty..
hi this is superb script…
but i got some errors
Warning: imap_open() [function.imap-open]: Couldn’t open stream {imap.gmail.com:993/imap/ssl}INBOX in /home/ospreyan/public_html/kushal/mail.php on line 8
Cannot connect to Gmail: Can’t connect to gmail-imap.l.google.com,993: Connection refused
can you help me in that
If you are using localhost and having problems, look into XAMPP instead of WAMP
this is very good idea…..
Can you help me to take the html code of each mail….. and also need to display only the unreaded messages ….. please help me sir…..
It doesn’t seem to work with Danish characters, any suggestions?
its working well for me .. i m using this with my own server not with gmail. thanks for this great effort…..
great, thank you!
hi david,
can we use jquery instead of using mootools javascript.
if u have problem with certificate, add /novalidate-cert
imap.gmail.com:993/imap/ssl/novalidate-cert
if you cant connect then its the port 993 which is blocked (outbound blocking)
i have great ideas to use this, muahahahaaha(evil laughter)
Warning: imap_open() [function.imap-open]: Couldn’t open stream {imap.gmail.com:993/imap/ssl}INBOX in \\hmfsw\web\dtcwin071\6700.com.ar\public_html\ver\mail.php on line 8
Cannot connect to Gmail: Can’t connect to gmail-imap.l.google.com,993: Host unreachable the php say’s that, i be read about this and say’s “993 port is locked by firewall” what i can do?
@deepak: your PHP implementation probably requires <?php, not just <? on the first line
@Bob Snider: Its an atachment – you need to read up on mime and how to parse email
david, amazing! can it retrieve also the sent mails? or even user generated folders? i will be studying this IMAP thing.. thanks for the great idea! feed on!
@David Walsh: i seem to be having the same problem as nimz where i’m getting “Cannot connect to Gmail: Too many login failures” even though my accounts are perfectly fine?
Thank you, David, very useful stuff.
Something strange in folder structure, where does Google store spam…
Hi David,
Just wanted to know if we could also acquire the attachments with the email as well.
If this is possible please let me know..
In advance,
Thanks for your help..
hey david can you please post the whole script here at your blog, because i think your codes are incomplete and i cannot see sliding animation in my page…
Thanks
Wel the script is 100% working, but i want to know how to paginate the inbox to multiple pages, can anybody tell me?
Interesting technique, and I like how you included the accordian to make things more interesting.
Do we really need another PHP mail app though? :) Integration possibilities are endless though of course.
Excellent lesson. I have a question. Im using it to retreive an overview of my gmail into my private intranet. Works great but I would like to make every subject link back to the gmail account directly.. i know i need to get some kind of ID for each mail then redirect to mail.google.com/#inbox or something.. any ideas?
Thanks david really helpfull
@Iván: Ivan its prob with your config file…go to php.ini and enable (extension_imap blah blah)…and you are done…
Hi,
First of: Great code example, gets a man up and running in no time! Big thanks.
Second: have you been folowing the release of gMail IMAP + oAuth?
That opens the door to all sorts of weird and wonderful opertunities… anything from “Open your gmail from my website” to a Gmail Facebook Tab (because, lets be honest, the current implementations suck :-)
greetz,
P.
I saved the php code in a TextWrangler document and uploaded it, but on my localhost (MAMP with an IMAP code edit) that delivers a blank page and on x10hosting, I get the following:
Parse error: syntax error, unexpected $end in /home/r5radar/public_html/walsh.php on line 70
(I have a thorough understanding of HTML, have some experience with XML, and am just learning php)
How should the accordion, CSS and php codes be saved? I just want to get this awesome code to work before I embed it in an actual page or design…
@eicky: i think you need to copy the dll into your php directory as well…
Alright I think I have the ssl and firewall issues solved (I’m on a mac), but I’ve come to an unexpected T_STRING error on line 55 I can’t see. Here’s my code:
Gmail to RSS test
window.addEvent(‘domready’,function() {
var togglers = $$(‘div.toggler’);
if(togglers.length) var gmail = new Fx.Accordion(togglers,$$(‘div.body’));
togglers.addEvent(‘click’,function() { this.addClass(‘read’).removeClass(‘unread’); });
togglers[0].fireEvent(‘click’); //first one starts out read
});
<?php
$formatcss = "
";
echo $formatcss;
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'route5radarproxy@gmail.com';
$password = 'gothrough';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inbox,'ALL');
/* if emails are returned, cycle through each… */
if($emails) {
/* begin output var */
$output = ";
/* put the newest emails on top */
rsort($emails);
/* for every email… */
foreach($emails as $email_number) {
/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_fetchbody($inbox,$email_number,2);
/* output the email header information */
$output.= 'seen ? ‘read’ : ‘unread’).’”>’;
$output.= ”.$overview[0]->subject.’ ‘;
$output.= ‘on ‘.$overview[0]->date.”;
$output.= ”;
/* output the email body */
$output.= ”.$message.”;
}
echo $output;
}
/* close the connection */
imap_close($inbox);
?>
/*
Gmail to RSS test
window.addEvent(‘domready’,function() {
var togglers = $$(‘div.toggler’);
if(togglers.length) var gmail = new Fx.Accordion(togglers,$$(‘div.body’));
togglers.addEvent(‘click’,function() { this.addClass(‘read’).removeClass(‘unread’); });
togglers[0].fireEvent(‘click’); //first one starts out read
});
<?php
$formatcss = "
";
echo $formatcss;
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'route5radarproxy@gmail.com';
$password = 'gothrough';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inbox,'ALL');
/* if emails are returned, cycle through each… */
if($emails) {
/* begin output var */
$output = ";
/* put the newest emails on top */
rsort($emails);
/* for every email… */
foreach($emails as $email_number) {
/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_fetchbody($inbox,$email_number,2);
/* output the email header information */
$output.= 'seen ? ‘read’ : ‘unread’).’”>’;
$output.= ”.$overview[0]->subject.’ ‘;
$output.= ‘on ‘.$overview[0]->date.”;
$output.= ”;
/* output the email body */
$output.= ”.$message.”;
}
echo $output;
}
/* close the connection */
imap_close($inbox);
?>
*/
@Dan: Please help me Dan
Warning: imap_open() [function.imap-open]: Couldn’t open stream {imap.gmail.com:993/imap/ssl}INBOX in C:\xampp\htdocs\POC\test.php on line 24
Cannot connect to Gmail: Can’t open mailbox {imap.gmail.com:993/imap/ssl}INBOX: invalid remote specification
it was a firewall is connecting 993.
Still i am getting above error
Regards,
Naresh
Hi all,
David ur script really nice, But i want mail download from pop3, if u have any idea for that, Please help me…
Thanks & Regards,
Vinoth S
I’m download the mail from local(means my company) mail server, and the values are spilit and stored into DB, But its a POP amail server, so if u have a idea or something please help me….
How modify code only view 5 last new mail receive on gmail inbox?
hai david i tried lot of time.but it will not connect with gmail.it say folling errors
{imap.gmail.com:993/imap/ssl}INBOX in /home/ospreyan/public_html/kushal/mail.php on line 8
Cannot connect to Gmail: Can’t connect to gmail-imap.l.google.com,993: Connection time out
Hi, i m receiveing this
Warning: imap_open() [function.imap-open]: Couldn’t open stream {imap.gmail.com:993/imap/ssl}INBOX in /home/uppstu5/public_html/test_gmail.php on line 8
Cannot connect to Gmail: Too many login failures
Plz help me