沃梦达 / 编程问答 / php问题 / 正文

使用 PHP & 连接到 Gmail地图

Connect to Gmail with PHP amp; IMAP(使用 PHP amp; 连接到 Gmail地图)

本文介绍了使用 PHP & 连接到 Gmail地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从我的 php.ini 文件中启用了 OpenSSLIMAP 函数,并且 phpinfo() 确认了它.

I have enabled OpenSSL and IMAP functions from my php.ini file and phpinfo() confirms it.

通过使用下面的代码,我可以连接到 Hotmail 帐户,但不能连接到 Gmail 帐户.(当然,我将 $connect_to 更改为指向 Hotmail.)

By using the code below i can connect to a Hotmail account but not to a Gmail account.(of course i change the $connect_to to point to Hotmail.)

$connect_to = '{imap.gmail.com:993/imap/ssl}INBOX';
$connection = imap_open($connect_to, $user, $password)
  or die("Can't connect to '$connect_to': " . imap_last_error());
imap_close($connection);

返回的错误是

Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /opt/lampp/htdocs/webmail_client_practise/index.php on line 6
Can't connect to '{imap.gmail.com:993/imap/ssl}INBOX': Certificate failure for imap.gmail.com: unable to get local issuer certificate: /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
Notice: Unknown: Certificate failure for imap.gmail.com: unable to get local issuer certificate: /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA (errflg=2) in Unknown on line 0

很遗憾,我找不到有关如何使用 IMAP 功能的完整教程.

Unfortunately i cannot find a complete tutorial of how to use the IMAP functions.

任何想法、解决方案或建议都会有所帮助.

Any ideas, solutions or suggestions will be helpful.

推荐答案

更新:

在互联网上搜索我的问题后,我没有找到完全解决我的问题的解决方案.虽然如果

After searching for my problem on the Internet, i did not found a solution that solves my problem completely. Although if

1) 我使用不安全的 $connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';

1) I use the insecure $connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';

2)并允许安全性较低的应用程序访问gmail,

2)And allow gmail to be accessed by less secured apps,

暂时解决了我的问题.

请查看此https://support.google.com/accounts/answer/6010255?hl=zh-CN

这篇关于使用 PHP & 连接到 Gmail地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 PHP & 连接到 Gmail地图

基础教程推荐