I'm not clear on what your getting when connecting on port 993. It sounds like a firewall issue to me.
If you want to set cert options you can do that with the following config option:
// IMAP socket context options
// See http://php.net/manual/en/context.ssl.php
// The example below enables server certificate validation
//
// proxy_protocol is used to inject HAproxy style headers in the TCP stream
// See http://www.haproxy.org/download/1.6/doc/proxy-protocol.txt
// WARNING: Please note this is currently incompatible with implicit ssl,
// since the proxy protocol preamble is expected before the ssl handshake.
// $config['imap_conn_options'] = [
// 'ssl' => [
// 'verify_peer' => true,
// 'verify_depth' => 3,
// 'cafile' => '/etc/openssl/certs/ca.crt',
// ],
// 'proxy_protocol' => 1 | 2 | [ // required (either version number (1|2) or array with 'version' key)
// 'version' => 1 | 2, // required, if array
// 'remote_addr' => $_SERVER['REMOTE_ADDR'], // optional
// 'remote_port' => $_SERVER['REMOTE_PORT'], // optional
// 'local_addr' => $_SERVER['SERVER_ADDR'], // optional
// 'local_port' => $_SERVER['SERVER_PORT'], // optional
// ],
// ];
// Note: These can be also specified as an array of options indexed by hostname
$config['imap_conn_options'] = null;
That said I would expect a different error if it was a certificate problem.