Gmail IMAP with PHP?

北战南征 提交于 2019-12-23 19:27:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!