无法连接到gmail-imap.l.google.com,993:拒绝连接

<?php
require "vendor/autoload.php";

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'mail@gmail.com';
$password = 'password';
$inbox = imap_open($hostname,$username ,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

He constantly writes that access is denied. The feeling of being closed by Google security. Where to allow access for no message:

Can't connect to gmail-imap.l.google.com, 993: Connection refused

Website https://pomidor.cc

Something on your network -- possibly a firewall -- is blocking your connection to the Google mail server. Contact your system administrator or hosting provider for details.

From the information you provided, it looks like a problem related with a missing certificate on your end. Here are a couple of questions with workarounds/solutions [1][2].

You may also consider to start using the Gmail API which allows you to do several actions in a simple way. You can enable the IMAP setting [3] and set the quickstart so you can start making requests from there [4].

[1] Connect to Gmail with PHP & IMAP

[2] Certificate error using IMAP in PHP

[3] https://developers.google.com/gmail/api/v1/reference/users/settings/updateImap

[4] https://developers.google.com/gmail/api/quickstart/php