问题
I'm trying to connect to my Gmail account in PHP via IMAP but I always get an error that says it can't open stream. I've tried lots of different things to fix this but I've had no luck. By the way, I'm using 000webhost.com to host my website and they say that they support IMAP. Here's my code:
$server="{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX";
$inbox = imap_open($server,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
For the $username and $password, I'm using my Gmail Email and password (e.g. myemail@gmail.com and mygmailpassword) Any ideas?
回答1:
In GMAIL you have to enable IMAP:
in your gmail account, go to: Settings -> Forwarding and POP/IMAP-->enable IMAP
来源:https://stackoverflow.com/questions/9755865/gmail-imap-with-php