6use Bitrix\Main\Text\Encoding;
7use Bitrix\Main\Localization\Loc;
9Loc::loadMessages(__FILE__);
51 $this->options =
array(
55 'socket' => sprintf(
'%s://%s:%s', ($tls ?
'ssl' :
'tcp'),
$host, $port),
56 'timeout' => \COption::getOptionInt(
'mail',
'connect_timeout',
B_MAIL_TIMEOUT),
57 'context' => stream_context_create(
array(
59 'verify_peer' => (
bool) $strict,
60 'verify_peer_name' => (
bool) $strict,
61 'crypto_method' => STREAM_CRYPTO_METHOD_ANY_CLIENT,
87 if (!is_null($this->stream))
89 @fclose($this->stream);
117 $resource = @stream_socket_client(
118 $this->options[
'socket'], $errno, $errstr, $this->options[
'timeout'],
119 STREAM_CLIENT_CONNECT, $this->options[
'context']
122 if ($resource ===
false)
128 $this->stream = $resource;
130 if ($this->options[
'timeout'] > 0)
132 stream_set_timeout($this->stream, $this->options[
'timeout']);
137 if (
false === $prompt)
141 else if (!preg_match(
'/^ 220 ( \r\n | \x20 ) /x', end($prompt)))
156 if (!$this->options[
'tls'] && preg_grep(
'/^ STARTTLS $/ix', $this->sessCapability))
187 if (stream_socket_enable_crypto($this->stream,
true, STREAM_CRYPTO_METHOD_ANY_CLIENT))
218 Main\Context::getCurrent()->getRequest()->getHttpHost() ?:
'localhost'
231 $this->sessCapability = array_map(
234 return trim(mb_substr($line, 4));
259 if ($capabilities = preg_grep(
'/^ AUTH \x20 /ix', $this->sessCapability))
265 else if (preg_grep(
'/ \x20 PLAIN ( \x20 | $ ) /ix', $capabilities))
269 else if (preg_grep(
'/ \x20 LOGIN ( \x20 | $ ) /ix', $capabilities))
281 if ($mech ===
'oauth')
283 $token = Helper\OAuth::getTokenByMeta($this->options[
'password']);
289 $formatted = sprintf(
"user=%s\x01auth=Bearer %s\x01\x01", $this->options[
'login'], $token);
292 else if ($mech ===
'plain')
297 base64_encode(sprintf(
299 Encoding::convertEncoding($this->options[
'login'], $this->options[
'encoding'],
'UTF-8'),
300 Encoding::convertEncoding($this->options[
'password'], $this->options[
'encoding'],
'UTF-8')
309 "AUTH LOGIN\x00%s\x00%s",
310 base64_encode($this->options[
'login']),
311 base64_encode($this->options[
'password'])
336 $chunks = explode(
"\x00", $command);
339 foreach ($chunks as $chunk)
345 if (
$k > 0 && mb_strpos(end(
$response),
'3') !== 0)
372 if (!preg_match(
'/^ [23] \d{2} /ix', end(
$response)))
383 while (strlen(
$data) > 0 && !feof($this->stream))
389 if (
false ===
$bytes || ++$fails >= 3)
402 if (strlen(
$data) > 0)
415 while (!feof($this->stream))
417 $buffer = @fgets($this->stream, 4096);
423 $meta = ($this->options[
'timeout'] > 0 ? stream_get_meta_data($this->stream) :
array(
'timed_out' =>
false));
433 if (!preg_match(
'/\r\n$/', $line,
$matches))
462 while (!preg_match(
'/^ \d{3} ( \r\n | \x20 ) /x', $line));
470 $details = array_filter((
array) $details);
481 $error .= sprintf(
' (SMTP: %s)', join(
': ', $details));
483 $this->errors->setError(
new Main\
Error(
'SMTP', -1));
484 foreach ($details as $item)
486 $this->errors->setError(
new Main\
Error((
string) $item, -1));
513 case self::ERR_CONNECT:
514 return Loc::getMessage(
'MAIL_SMTP_ERR_CONNECT');
515 case self::ERR_REJECTED:
516 return Loc::getMessage(
'MAIL_SMTP_ERR_REJECTED');
517 case self::ERR_COMMUNICATE:
518 return Loc::getMessage(
'MAIL_SMTP_ERR_COMMUNICATE');
519 case self::ERR_EMPTY_RESPONSE:
520 return Loc::getMessage(
'MAIL_SMTP_ERR_EMPTY_RESPONSE');
522 case self::ERR_STARTTLS:
523 return Loc::getMessage(
'MAIL_SMTP_ERR_STARTTLS');
524 case self::ERR_COMMAND_REJECTED:
525 return Loc::getMessage(
'MAIL_SMTP_ERR_COMMAND_REJECTED');
526 case self::ERR_CAPABILITY:
527 return Loc::getMessage(
'MAIL_SMTP_ERR_CAPABILITY');
529 return Loc::getMessage(
'MAIL_SMTP_ERR_AUTH');
530 case self::ERR_AUTH_MECH:
531 return Loc::getMessage(
'MAIL_SMTP_ERR_AUTH_MECH');
534 return Loc::getMessage(
'MAIL_SMTP_ERR_DEFAULT');
547 $this->isOauth = $value;
const ERR_COMMAND_REJECTED
errorMessage($errors, $details=null)
executeCommand($command, &$error)
static decodeError($code)
__construct($host, $port, $tls, $strict, $login, $password, $encoding=null)
if(!defined("ADMIN_AJAX_MODE") &&(($_REQUEST["mode"] ?? '') !='excel')) $buffer
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"