- Модуль: mail
- Путь к файлу: ~/bitrix/modules/mail/classes/general/mail.php
- Класс: CAllMailBox
- Вызов: CAllMailBox::Check
function Check($server, $port, $use_tls, $login, $passw)
{
if (($use_tls == 'Y' || $use_tls == 'S') && !preg_match('#^(tls|ssl)://#', $server))
$server = 'ssl://' . $server;
$skip_cert = $use_tls != 'Y';
$pop3_conn = &$this->pop3_conn;
$pop3_conn = stream_socket_client(
sprintf('%s:%s', $server, $port),
$errno, $errstr,
COption::getOptionInt('mail', 'connect_timeout', B_MAIL_TIMEOUT),
STREAM_CLIENT_CONNECT,
stream_context_create(array('ssl' => array('verify_peer' => !$skip_cert, 'verify_peer_name' => !$skip_cert)))
);
if(!$pop3_conn)
return array(false, GetMessage("MAIL_CL_TIMEOUT")." $errstr ($errno)");
$this->GetResponse();
$greeting = $this->GetResponseString();
$this->SendCommand("USER ".$login);
if(!$this->GetResponse())
return array(false, GetMessage("MAIL_CL_ERR_USER").' ('.$this->GetResponseString().')');
$this->SendCommand("PASS ".$passw);
if(!$this->GetResponse())
return array(false, GetMessage("MAIL_CL_ERR_PASSWORD").' ('.$this->GetResponseString().')');
$this->SendCommand("STAT");
if(!$this->GetResponse())
return array(false, GetMessage("MAIL_CL_ERR_STAT").' ('.$this->GetResponseString().')');
$stat = trim($this->GetResponseBody());
$arStat = explode(" ", $stat);
return array(true, $arStat[1]);
}