IMAP: Can't connect to imap.gmail.com,993: Network is unreachable

I’m establishing IMAP connection with this:

$host = "imap.gmail.com";
$port = "993";
$ssl = "imap/ssl/validate-cert";
$user = '[email protected]';
$password = 'pass';

$host = "{" . $host . ":" . $port . "/" . $ssl . "}INBOX";

$conn = imap_open($host, $user, $password)
        or die(imap_last_error());

It’s giving this error:
Can't connect to imap.gmail.com,993: Network is unreachable

But it’s working fine in my localhost.

Looking for help.
Thanks in advance.

That sounds an awful lot like the thread below. And with the same advice: This is not a Cloudflare issue, as Cloudflare has nothing to do with scripts connecting to third party mail providers.

1 Like

@sdayman Thanks for reply. But it’s working in my localhost. Please inform me the way to fix it.