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

11,364

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

Share:
11,364
Yaxing
Author by

Yaxing

Updated on June 17, 2022

Comments

  • Yaxing
    Yaxing about 2 years

    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!

  • rafiki_rafi
    rafiki_rafi almost 10 years
    Fixed the issue I was having - had OpenSSL as well as imap enabled, but was still getting the error. Re-compiled php --with-imap-ssl and is working now.