- Модуль: mail
- Путь к файлу: ~/bitrix/modules/mail/classes/general/imap.php
- Класс: CMailImap
- Вызов: CMailImap::connect
public function connect($host, $port, $timeout = 1, $skip_cert = false)
{
$imap_stream = @stream_socket_client(
sprintf('%s:%s', $host, $port), $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT,
stream_context_create(array('ssl' => array('verify_peer' => !$skip_cert, 'verify_peer_name' => !$skip_cert)))
);
if ($imap_stream === false)
throw new Exception(GetMessage('MAIL_IMAP_ERR_CONNECT'));
stream_set_timeout($imap_stream, $timeout);
$this->imap_stream = $imap_stream;
$prompt = $this->readLine();
if ($prompt === false)
throw new Exception(GetMessage('MAIL_IMAP_ERR_COMMUNICATE'));
if (mb_strpos($prompt, '* OK') !== 0)
{
$this->imap_stream = null;
throw new Exception(GetMessage('MAIL_IMAP_ERR_CONNECT').': '.GetMessage('MAIL_IMAP_ERR_BAD_SERVER'));
}
/*
$tag = $this->sendCommand("STARTTLSrn");
$res = $this->readResponse($tag);
if (strpos($res, $tag.' OK') !== false)
{
$a = stream_socket_enable_crypto($this->imap_stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
}
*/
}