PHP imap_open(): Couldn't open stream to gmail

4.5k Views Asked by At

I'm getting this messages when I tried to use php-imap to retrieve emails from server using IMAP protocol. I started with gmail accounts. But when I tried to connect using imap_open() I get the following messages:

Warning: imap_open(): Couldn't open stream {imap.gmail.com/imap/ssl:993}INBOX in \path\to\file\imap.php on line 6

or

Warning: imap_open(): Couldn't open stream {imap.gmail.com/imap/ssl/novalidate-cert:993}INBOX in \path\to\file\imap.php on line 6

depending if I use or not novalidate-cert

I found some related question, but not the solution

imap_open(): Couldn't open stream

Getting Error like imap_open(): Couldn't open stream in server

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

Is it possible connect to email using the imap php extension? If, Yes. How can I solved this message?

If, No. Which alternative for received email using PHP could be possible?

1

There are 1 best solutions below

0
On

Try imap.gmail.com:993/imap/ssl. Port number comes after the domain name and befor the URI path.