Connecting To Gmail IMAP PHP "Couldn't Open Stream"


Answer :

You need port 993, the SSL IMAP port.



Port 995 is the SSL POP3 port.



I think Gmail's IMAP can only be accessed on port 993.



$hostname = "{imap.gmail.com:993/imap/ssl/novalidate-cert}";



I had the same error and found a different solution. I have added debug info into host:



"{imap.gmail.com:993/debug/imap/ssl/novalidate-cert}INBOX"; 


When I read php error log, I found



Unknown: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) (errflg=1) in Unknown on line 0


Open link, and follow instructions. Search for




Your app might not support the latest security standards. Try changing
a few settings to allow less secure apps access to your account.




Click on link and enable less secure app access.



Then it works for me.



Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable