Gmail的IMAP与PHP? [英] Gmail IMAP with PHP?

查看:129
本文介绍了Gmail的IMAP与PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过IMAP连接到我的Gmail帐户,但是我总是收到一条错误消息,说它无法打开流。我已经尝试了很多不同的事情来解决这个问题,但我没有运气。顺便说一下,我使用000webhost.com来托管我的网站,他们说他们支持IMAP。这里是我的代码:

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());

对于$ username和$ password,我使用我的Gmail电子邮件和密码(例如myemail @ gmail.com和mygmailpassword)
任何想法?

For the $username and $password, I'm using my Gmail Email and password (e.g. myemail@gmail.com and mygmailpassword) Any ideas?

推荐答案

在GMAIL中,您必须启用IMAP:

In GMAIL you have to enable IMAP:

在您的Gmail帐户中,转到:设置 - >转发和POP / IMAP - >启用IMAP

in your gmail account, go to: Settings -> Forwarding and POP/IMAP-->enable IMAP

这篇关于Gmail的IMAP与PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆