PHP failing to connect to GMail via IMAP [Edited!!]

gmailimapPHPphp5ssl

I have some php code that I'm trying to use to connect to gmail using imap. Here's the code:

$hostname = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
$tmp_username = 'username';
$tmp_password = 'password';
$inbox = imap_open($hostname, $username, $password) or die(imap_last_error());

And I get this error output everytime i try to connect:

Warning: imap_open()
[function.imap-open]: Couldn't open
stream
{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX
in /var/www/PHP/EmailScript.php on
line 14 Login aborted

I dont understand what could be wrong!! I've heard of people having SSL errors but this doesnt seem to be one of those. Please please please help me!!!!!

Edit: When trying to connect to imap.gmail.com through telnet-ssl i get the following output:

Trying 74.125.155.109…
Connected to gmail-imap.l.google.com.
Escape character is '^]'.

And Nothign else happens

Best Answer

Use this command to start up the session....

openssl s_client -connect imap.gmail.com:993

if I do that I get this...

* OK Gimap ready for requests from <ip_address> 16if41262875qci.66

Related Topic