How to retrieve email from GMail account using PHP?

Posted by Tatu Ulmanen on Stack Overflow See other posts from Stack Overflow or by Tatu Ulmanen
Published on 2010-06-17T11:48:06Z Indexed on 2010/06/17 11:53 UTC
Read the original article Hit count: 272

Filed under:
|
|

Hi,

I'm trying to automatically retrieve some email from my GMail account for further parsing, but I can't get my head around on how to do that. I've searched the internets and it suggested that I use PHP's imap functions, like this:

$server = '{imap.gmail.com:993/ssl}';
$connection = imap_open($server, '[email protected]', 'password');

But using that code, I get:

Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/ssl}

Any idea what I am doing wrong? Any server setting that might be preventing me from making a connection to GMail (I'm using a shared service)? Is the address even right? Has anyone ever managed to do something like this? I've found tons of examples on how to send email via GMail, but very little of retrieving.

Any help is much appreciated.

© Stack Overflow or respective owner

Related posts about php

Related posts about email