PHP imap_open():尝试连接到 GMAIL 时远程规范无效
我尝试从 Gmail 检索邮件并收到以下错误:
Can't open mailbox {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX: invalid remote specification
我的服务器中安装了 OpenSSL 和 IMAP,以下是 openssl 和 IMAP来自 phpinfo() 的 imap 信息;
openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 0.9.7l 28 Sep 2006
OpenSSL Header Version
imap
IMAP c-Client Version 2007e
Kerberos Support enabled
我现在真的很困惑,请帮忙!
I'm trying to retrive mails from Gmail and got following error:
Can't open mailbox {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX: invalid remote specification
OpenSSL and IMAP are installed in my server, following are openssl & imap info from phpinfo();
openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 0.9.7l 28 Sep 2006
OpenSSL Header Version
imap
IMAP c-Client Version 2007e
Kerberos Support enabled
I'm really confused now, please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也遇到过类似的问题。我可以根据个人经验告诉您,虽然您可能安装了 IMAP 和 OpenSSL,但您可能需要重新编译 php install“--with-imap-ssl[=DIR]”。我想做同样的事情并收到同样的错误。我还安装了相同的 OpenSSL 和 IMAP 版本。我已经重新编译了 php,这是我的配置:
你当然不需要使用相同的配置,因为它是根据我的需要定制的。
如果您不熟悉编译 php,可以在这里找到源代码:
http://www.php.net/downloads.php
这是关于如何编译 php 和 apache 的基本教程,假设您使用的是 UNIX。它还包括如何使用curl编译它们,您可以使用curl的所有指令并分别用ssl和imap替换它们,它应该可以工作。
http://thermo.sdsu.edu/testhome/phpinstall.html
I have been having a similar issue. I can tell you from personal experience that while you may have IMAP and OpenSSL installed, you may need to recompile php install "--with-imap-ssl[=DIR]." I wanted to do the same thing and received the same error. I also had the same OpenSSL and IMAP versions installed. I have recompiled php, and here is my config:
You don't need to use the same config of course, because it is customized for what I need.
In case you are unfamiliar with compiling php, you can find the source here:
http://www.php.net/downloads.php
Here's a basic tutorial on how to compile php and apache, assuming you are on UNIX. It also includes how to compile them with curl, you can use all of the instructions for curl and replace them with ssl and imap respectively and it should work.
http://thermo.sdsu.edu/testhome/phpinstall.html
对于 Docker,我了解到在调用
docker-php-ext-install
之前docker-php-ext-configure
时会发生此错误,我就是这样做的误。因此,Dockerfile
中的RUN
指令必须如下所示:而不是
否则,imap 扩展似乎已安装 - 类似
function_exists('imap_open')< 的调用/code> 将返回 true。但所有对
imap_open
的调用将因上述错误而失败:
即使它是已被广泛证明的正确远程规范,例如
{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}INBOX
或{imap. gmail.com:993/imap/ssl}INBOX
来自例如 这篇文章。因此,请确保首先配置然后安装扩展。For Docker I learned that this error occurs when calling
docker-php-ext-install
beforedocker-php-ext-configure
, which I did by mistake. So theRUN
directive in theDockerfile
must look like this:instead of
Otherwise, the imap extension seems to be installed - calls like
function_exists('imap_open')
will return true. But all calls toimap_open
will fail with the mentioned error:
Even if it's a correct remote specification which has been widely prooven like
{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}INBOX
or{imap.gmail.com:993/imap/ssl}INBOX
from e.g. this article. So make sure that you first configure and then install the extension.检查此代码,这将连接到 gmail 服务器。
Check this code this will connect to gmail server .