Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

imap

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!

like image 703
Yaxing Avatar asked Jul 17 '11 22:07

Yaxing


1 Answers

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

like image 79
jstrieb Avatar answered Nov 08 '22 20:11

jstrieb