snappymail/build/test_ssl_connection.php

31 lines
606 B
PHP
Raw Normal View History

2015-04-25 06:15:11 +08:00
<?php
// simple connection test
$host = 'imap.gmail.com';
$port = 993;
echo $host.':'.$port;
2017-10-02 01:54:50 +08:00
$streamContextSettings = array(
'ssl' => array(
'verify_host' => true,
'verify_peer' => true,
'verify_peer_name' => true,
'allow_self_signed' => false
)
);
$streamContext = stream_context_create($streamContextSettings);
2015-04-25 06:15:11 +08:00
$errorStr = '';
$errorNo = 0;
2017-10-02 01:54:50 +08:00
$connection = stream_socket_client($host.':'.$port, $errorNo, $errorStr, 5, STREAM_CLIENT_CONNECT, $streamContext);
2015-04-25 06:15:11 +08:00
if (is_resource($connection)) {
echo ' = OK';
fclose($connection);
} else {
echo ' = ERROR ([#'.$errorNo.'] '.$errorStr.')';
2017-10-02 01:54:50 +08:00
}