PHP imap_open(): invalid remote specification when trying connect to GMAIL

China☆狼群 提交于 2019-12-23 09:49:41

问题


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!


回答1:


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:

./configure --prefix=/usr/local/apache2/php --with-imap=/usr/local/imap-2007f/ --with-curl=/usr/local/curl/ --enable-sockets --with-imap-ssl=/usr/local/ssl --with-openssl --with-apxs2=/usr/local/apache2/bin/apxs --with-kerberos --without-iconv

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




回答2:


 $iconnect = imap_open("{imap.gmail.com:993/ssl/novalidate-cert}INBOX","user@gmail.com","passwordofuser") or die(imap_errors());

Check this code this will connect to gmail server .



来源:https://stackoverflow.com/questions/6727276/php-imap-open-invalid-remote-specification-when-trying-connect-to-gmail

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