Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Gmail IMAP PHP "Couldn't open stream"

There are lots of people having similar issues but no one is answering their questions. I have IMAP enabled in PHP, Using all the correct information. I don't see where I'm going wrong.

Here's my code:

$hostname = '{imap.gmail.com:995/imap/ssl/novalidate-cert}'; 
$username = '[email protected]'; $password = 'password'; 
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

print_r(imap_errors());

Not returning any errors other than:

Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:995/imap/ssl/novalidate-cert} in /home/a8066360/public_html/test/imap.php on line 6

Cannot connect to Gmail: Can't connect to gmail-imap.l.google.com, 995: Connection timed out

I've noticed that if I change the single quotes to `

shell_exec() has been disabled for security reasons...

Please help!!!

like image 207
cream Avatar asked Aug 02 '12 06:08

cream


People also ask

Why is my Gmail IMAP not working?

Generally, the error related to the IMAP protocol is due to the wrong settings, improper connection, slow Internet speed, or the outdated version of the email client. First, you should check all these aspects and accordingly correct them. It might turn the Gmail account into working smoothly like before.

What is PHP IMAP?

IMAP stands for Internet Mail Access Protocol, PHP-IMAP functions helps you to access an email account and fetch emails from them. Using these functions you can also work with NNTP, POP3 protocols and local mailbox access methods. With the help of this library you can create web applications that handle your emails.


1 Answers

You need port 993, the SSL IMAP port.

Port 995 is the SSL POP3 port.

like image 131
Max Avatar answered Sep 22 '22 19:09

Max