PHP imap_open() error – INBOX: invalid remote specification (errflg=2)

INBOX: invalid remote specification (errflg=2)

 

Got following error when use imap_open() in PHP?

 

Notice: Unknown: Can't open mailbox {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX: invalid remote specification (errflg=2) in Unknown on line 0

 

Check imap enabled SSL support like screenshot

screen-shot-2016-10-31-at-2-08-08-am

 

If cannot see SSL Support configuration, then need re-compile imap.so with enabling SSL support.

 

 

PHP IMAP connection test code

<?php
    ini_set('display_errors', 1);
    error_reporting(E_ALL);

    $imap_path = "{imap.google.com:993/imap/ssl/novalidate-cert}INBOX";
    $email_address = "email address";
    $email_password = "password";

    $mbox = imap_open ($imap_path, $email_address, $email_password);

    if($mbox === false) {
        echo "Connection failed";
    } else {
        echo "Connected";
        imap_close($mbox);
    }