Connect to Gmail with PHP amp; IMAP(使用 PHP amp; 连接到 Gmail地图)
问题描述
我已经从我的 php.ini
文件中启用了 OpenSSL
和 IMAP
函数,并且 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地图


- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Laravel 仓库 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01