6use Bitrix\Main\Text\Encoding;
7use Bitrix\Main\Localization\Loc;
8use Bitrix\Main\Text\Emoji;
10Loc::loadMessages(__FILE__);
42 protected static $atomRegex =
'[^\x00-\x20\x22\x25\x28-\x2a\x5c\x5d\x7b\x7f-\xff]+';
43 protected static $qcharRegex =
'[^\x00\x0a\x0d\x22\x5c\x80-\xff]|\x5c[\x5c\x22]';
45 protected static $astringRegex =
'[^\x00-\x20\x22\x25\x28-\x2a\x5c\x7b\x7f-\xff]+';
51 $strict = (bool) $strict;
53 $this->options =
array(
57 'socket' => sprintf(
'%s://%s:%s', ($tls ?
'ssl' :
'tcp'),
$host, $port),
58 'timeout' => \COption::getOptionInt(
'mail',
'connect_timeout',
B_MAIL_TIMEOUT),
59 'context' => stream_context_create(
array(
61 'verify_peer' => $strict,
62 'verify_peer_name' => $strict,
63 'crypto_method' => STREAM_CRYPTO_METHOD_ANY_CLIENT,
72 if(isset($logParams[
"log_level"]) && $logParams[
"log_level"] > 0)
74 $this->logLevel = $logParams[
"log_level"];
75 if(isset($logParams[
"log_path"]) && $logParams[
"log_path"] <>
'')
77 $this->logPath = $logParams[
"log_path"];
89 if (!is_null($this->stream))
91 @fclose($this->stream);
100 unset($this->sessState);
101 unset($this->sessCapability);
102 $this->sessCounter = 0;
103 $this->sessUntagged =
array();
104 $this->sessMailbox =
array(
107 'uidvalidity' =>
null,
108 'permanentflags' =>
null,
115 return $this->sessState;
122 if (!empty($this->sessState))
125 $resource = @stream_socket_client(
126 $this->options[
'socket'], $errno, $errstr, $this->options[
'timeout'],
127 STREAM_CLIENT_CONNECT, $this->options[
'context']
130 if ($resource ===
false)
136 $this->stream = $resource;
138 if ($this->options[
'timeout'] > 0)
139 stream_set_timeout($this->stream, $this->options[
'timeout']);
143 if ($prompt !==
false && preg_match(
'/^\* (OK|PREAUTH)/i', $prompt,
$matches))
146 $this->sessState =
'no_auth';
148 $this->sessState =
'auth';
152 if ($prompt ===
false)
153 $error = Imap::ERR_EMPTY_RESPONSE;
154 elseif (preg_match(
'/^\* BYE/i', $prompt))
155 $error = Imap::ERR_REJECTED;
157 $error = Imap::ERR_BAD_SERVER;
167 if (!$this->options[
'tls'] && preg_match(
'/ \x20 STARTTLS ( \x20 | \r\n ) /ix', $this->sessCapability))
180 if (!$this->sessState)
196 if (stream_socket_enable_crypto($this->stream,
true, STREAM_CRYPTO_METHOD_ANY_CLIENT))
218 if (!$this->sessState)
234 $regex =
'/^ \* \x20 CAPABILITY /ix';
235 foreach ($this->
getUntagged($regex,
true) as $item)
236 $this->sessCapability = $item[0];
247 if (in_array($this->sessState,
array(
'auth',
'select')))
253 if (preg_match(
'/ \x20 AUTH=XOAUTH2 ( \x20 | \r\n ) /ix', $this->sessCapability))
255 $token = Helper\OAuth::getTokenByMeta($this->options[
'password']);
261 else if (
false === $token)
270 if (preg_match(
'/ \x20 AUTH=PLAIN ( \x20 | \r\n ) /ix', $this->sessCapability))
272 elseif (!preg_match(
'/ \x20 LOGINDISABLED ( \x20 | \r\n ) /ix', $this->sessCapability))
282 if ($mech ==
'oauth')
295 "user=%s\x01auth=Bearer %s\x01\x01", $this->options[
'login'], $token
315 Encoding::convertEncoding($this->options[
'login'], $this->options[
'encoding'],
'UTF-8'),
316 Encoding::convertEncoding($this->options[
'password'], $this->options[
'encoding'],
'UTF-8')
323 static::prepareString($this->options[
'login']),
324 static::prepareString($this->options[
'password'])
336 $this->sessState =
'auth';
350 if ($this->sessState ==
'select' && $mailbox == $this->sessMailbox[
'name'])
351 return $this->sessMailbox;
354 'SELECT "%s"', static::escapeQuoted($this->
encodeUtf7Imap($mailbox))
365 $this->sessState =
'select';
366 $this->sessMailbox =
array(
369 'uidvalidity' =>
null,
372 $regex =
'/^ \* \x20 ( \d+ ) \x20 EXISTS /ix';
373 foreach ($this->
getUntagged($regex,
true) as $item)
374 $this->sessMailbox[
'exists'] = $item[1][1];
376 $regex =
'/^ \* \x20 OK \x20 \[ UIDVALIDITY \x20 ( \d+ ) \] /ix';
377 foreach ($this->
getUntagged($regex,
true) as $item)
378 $this->sessMailbox[
'uidvalidity'] = $item[1][1];
381 '/^ \* \x20 OK \x20 \[ PERMANENTFLAGS \x20 \( ( ( \x5c? %1$s | \x5c \* ) ( \x20 (?2) )* )? \) \] /ix',
384 foreach ($this->
getUntagged($regex,
true) as $item)
386 $this->sessMailbox[
'permanentflags'] = explode(
"\x20", $item[1][1]);
392 return $this->sessMailbox;
403 'EXAMINE "%s"', static::escapeQuoted($this->
encodeUtf7Imap($mailbox))
416 $regex =
'/^ \* \x20 ( \d+ ) \x20 EXISTS /ix';
417 foreach ($this->
getUntagged($regex,
true) as $item)
418 $result[
'exists'] = $item[1][1];
420 $regex =
'/^ \* \x20 OK \x20 \[ UIDVALIDITY \x20 ( \d+ ) \] /ix';
421 foreach ($this->
getUntagged($regex,
true) as $item)
422 $result[
'uidvalidity'] = $item[1][1];
425 '/^ \* \x20 OK \x20 \[ PERMANENTFLAGS \x20 \( ( ( \x5c? %1$s | \x5c \* ) ( \x20 (?2) )* )? \) \] /ix',
428 foreach ($this->
getUntagged($regex,
true) as $item)
430 $result[
'permanentflags'] = explode(
"\x20", $item[1][1]);
462 if (!preg_match(
'/(([1-9]\d*|\*)(:(?2))?)(,(?1))*/', $range))
483 if ($this->sessMailbox[
'exists'] > 0)
485 $fetchUntaggedRegex =
'/^ \* \x20 ( \d+ ) \x20 FETCH \x20 \( ( .+ ) \) \r\n $/isx';
489 sprintf(
'%sFETCH %s %s',
$uid ?
'UID ' :
'', $range,
$select),
501 $shiftName =
function (&$item)
509 [a-z0-9]+ (?: \. [a-z0-9]+ )*
510 (?: \[ (?: [a-z0-9]+ (?: \. [a-z0-9]* )* (?: \x20 %s )* )? \] )?
518 if (preg_match($regex, $item,
$matches))
522 $item = substr($item, strlen(
$matches[0]));
528 $shiftValue =
function (&$item) use (&$shiftValue)
532 $tail =
' (?= [\x20)] | $ ) \x20? ';
534 if (substr($item, 0, 1) ===
'(')
536 $item = substr($item, 1);
540 while (strlen($item) > 0 && substr($item, 0, 1) !==
')')
542 $subresult = $shiftValue($item);
544 if (
false !== $subresult)
554 if (preg_match(
'/^ \) (?= [\x20()] | $ ) \x20? /ix', $item,
$matches))
556 $item = substr($item, strlen(
$matches[0]));
563 else if (preg_match(
'/^ { ( \d+ ) } \r\n /ix', $item,
$matches))
565 $item = substr($item, strlen(
$matches[0]));
573 if (preg_match(sprintf(
'/^ %s /ix', $tail), $item,
$matches))
575 $item = substr($item, strlen(
$matches[0]));
583 else if (preg_match(sprintf(
'/^ NIL %s /ix', $tail), $item,
$matches))
587 $item = substr($item, strlen(
$matches[0]));
589 else if (preg_match(sprintf(
'/^ " ( (?: %s )* ) " %s /ix', self::$qcharExtRegex, $tail), $item,
$matches))
593 $item = substr($item, strlen(
$matches[0]));
595 else if (preg_match(sprintf(
'/^ ( \x5c? %s ) %s /ix', self::$astringRegex, $tail), $item,
$matches))
599 $item = substr($item, strlen(
$matches[0]));
601 else if (preg_match(sprintf(
'/^ %s /ix', $tail), $item,
$matches))
605 $item = substr($item, strlen(
$matches[0]));
611 $bodystructure =
function (&$value) use (&$bodystructure)
613 if (!is_array($value) || !is_array($value[0]))
618 $value[0] = $bodystructure($value[0]);
619 $value[0] =
array($value[0]);
621 while (array_key_exists(1, $value) && is_array($value[1]))
623 $value[0][] = $bodystructure($value[1]);
625 array_splice($value, 1, 1);
628 while (
count($value[0]) == 1 &&
count($value[0][0]) == 1)
630 $value[0] = $value[0][0];
636 foreach ($this->
getUntagged($fetchUntaggedRegex,
true) as $item)
642 while (strlen($item[1][2]) > 0)
644 if ((
$name = $shiftName($item[1][2])) !==
false)
646 if (($value = $shiftValue($item[1][2])) !==
false)
648 if (in_array(mb_strtoupper(
$name),
array(
'BODY',
'BODYSTRUCTURE')))
650 $value = $bodystructure($value);
669 if ($outputFormat ===
'smart' && !preg_match(
'/[:,]/', $range))
671 $list =
reset($list);
687 $command =
'UID SEARCH SINCE '.date(
"j-M-Y", strtotime($internalDate)).
' BEFORE '.date(
'j-M-Y', strtotime($internalDate.
' +1 day'));
700 $regex =
'/^ \* \x20 SEARCH \x20 ( .+ ) \r\n $ /ix';
701 foreach ($this->
getUntagged($regex,
true) as $item)
703 preg_match_all(
'/\d+/', $item[1][1],$UIDs);
706 if(
count($UIDs) === 0 )
734 if (!($this->sessMailbox[
'exists'] > 0))
739 $command =
'SEARCH UNSEEN';
741 if(!is_null($startInternalDate))
743 $command .= (
' SINCE '.$startInternalDate->format(
'j-M-Y'));
755 $regex =
'/^ \* \x20 SEARCH \x20 ( .+ ) \r\n $ /ix';
756 foreach ($this->
getUntagged($regex,
true) as $item)
758 $unseen = preg_match_all(
'/\d+/', $item[1][1]);
768 if (!($uidMin <= $uidMax))
780 if (!($this->sessMailbox[
'exists'] > 0))
787 return $this->sessMailbox[
'exists'];
797 [$min,
$max] = $range;
801 if ($uidMin > 1 && $uidMin > $min)
803 $searches[] = sprintf(
'%u:%u', $min, $uidMin - 1);
806 if ($uidMax > 0 && $uidMax <
$max)
808 $searches[] = sprintf(
'%u:%u', $uidMax + 1,
$max);
811 if (!empty($searches))
823 $regex =
'/^ \* \x20 SEARCH \x20 ( .+ ) \r\n $ /ix';
824 foreach ($this->
getUntagged($regex,
true) as $item)
826 $new = preg_match_all(
'/\d+/', $item[1][1]);
842 if (!($this->sessMailbox[
'exists'] > 0))
847 $range = $this->
fetch(
false, $mailbox, sprintf(
'1,%u', $this->sessMailbox[
'exists']),
'(UID)',
$error);
849 if (empty($range) || empty($range[1]))
886 '/^ \* \x20 LIST \x20
887 \( (?<flags> ( \x5c? %1$s ( \x20 \x5c? %1$s )* )? ) \) \x20
888 (?<delim> NIL | " ( %2$s ) " ) \x20
889 (?<name> \{ \d+ \} | " ( %2$s )* " | %3$s ) \r\n
892 self::$atomRegex, self::$qcharRegex, self::$astringRegex
894 foreach ($this->
getUntagged($regex,
true) as $item)
902 if (preg_match(
'/^ " ( .+ ) " $/ix', $sdelim, $quoted))
904 $sdelim = static::unescapeQuoted($quoted[1]);
907 if (preg_match(
'/^ \{ ( \d+ ) \} $/ix', $sname, $literal))
909 $sname = substr(
$matches[
'ext'], 0, $literal[1]);
911 else if (preg_match(
'/^ " ( .* ) " $/ix', $sname, $quoted))
913 $sname = static::unescapeQuoted($quoted[1]);
919 if (mb_strtoupper($sdelim) !=
'NIL')
920 $sname = rtrim($sname, $sdelim);
924 'delim' => mb_strtoupper($sdelim) ==
'NIL' ?
'NIL' : $sdelim,
925 'flags' => preg_split(
'/\s+/i', $sflags, -1, PREG_SPLIT_NO_EMPTY),
943 $listGetter =
function ($parent =
null, $level = 0) use (&$listGetter, &$delimiter, &
$error)
945 $pattern = $parent ? sprintf(
'%s%s%%', $parent, $delimiter) :
'%';
954 foreach ($list as
$i => $item)
956 $item[
'title'] = $item[
'name'];
957 $item[
'level'] = $level;
963 preg_quote($parent,
'/'),
964 preg_quote($delimiter,
'/')
967 if (!preg_match($regex, $item[
'name']))
973 $item[
'title'] = preg_replace($regex,
'\1', $item[
'name']);
976 if ($item[
'name'] == $parent)
981 if ($item[
'delim'] ===
null)
986 $delimiter = $item[
'delim'];
988 if (!preg_grep(
'/^ \x5c ( Noinferiors | HasNoChildren ) $/ix', $item[
'flags']))
990 $children = $listGetter($item[
'name'], $level + 1);
1006 return array_values($list);
1009 $list = $listGetter();
1011 if (
false === $list)
1019 array(
'/ ( \x5c \* )+ /x',
'/ ( \% )+ /x'),
1020 array(
'.*', $delimiter ? sprintf(
'[^\x%s]*', bin2hex($delimiter)) :
'.*'),
1025 $listFilter =
function ($list) use (&$listFilter, $regex)
1027 foreach ($list as
$i => $item)
1029 if (!preg_match($regex, $item[
'name']))
1031 if (empty($item[
'children']))
1038 if (!empty($item[
'children']))
1040 $item[
'children'] = $listFilter($item[
'children']);
1042 if (empty($item[
'children']))
1044 unset($item[
'children']);
1051 $list = array_values($list);
1057 if (!preg_match($regex, $item[
'name']))
1059 $children = empty($item[
'children']) ?
array() : $item[
'children'];
1069 $list = $listFilter($list);
1071 $listHandler =
function ($list,
$path =
array()) use (&$listHandler, $regex, $flat)
1077 $item[
'path'] = array_merge(
$path,
array($item[
'title']));
1079 if (!empty($item[
'children']))
1081 $item[
'children'] = $listHandler($item[
'children'], $item[
'path']);
1086 if ($flat && !empty($item[
'children']))
1088 unset($list[
$i][
'children']);
1090 array_splice($list,
$i + 1, 0, $item[
'children']);
1091 $i +=
count($item[
'children']);
1095 return array_values($list);
1098 $list = $listHandler($list);
1112 if (is_array($mailbox))
1115 $mailbox = $mailbox[
'mailbox'];
1133 if (!($this->sessMailbox[
'exists'] > 0) ||
$params[
'offset'] + 1 > $this->sessMailbox[
'exists'])
1140 $params[
'limit'] = $this->sessMailbox[
'exists'] -
$params[
'offset'];
1143 $uidtoken = $this->sessMailbox[
'uidvalidity'];
1145 $list = $this->
fetch(
1154 !is_null($uidtoken) ?
array(
'UID') :
array(),
1155 array(
'INTERNALDATE',
'RFC822.SIZE',
'FLAGS')
1160 foreach ($list as $id =>
$data)
1164 'uid' => array_key_exists(
'UID',
$data) ?
$data[
'UID'] :
null,
1165 'date' => array_key_exists(
'INTERNALDATE',
$data) ?
$data[
'INTERNALDATE'] :
null,
1166 'size' => array_key_exists(
'RFC822.SIZE',
$data) ?
$data[
'RFC822.SIZE'] :
null,
1167 'flags' => array_key_exists(
'FLAGS',
$data) ?
$data[
'FLAGS'] :
array(),
1171 $list = array_filter(
1175 return isset($item[
'date'], $item[
'size'], $item[
'flags']);
1215 '%sSEARCH %s',
$uid ?
'UID ' :
'',
1219 function (
$name, $value)
1223 static::prepareString(
$name),
1224 static::prepareString($value)
1227 array_keys($header),
1228 array_values($header)
1243 $regex =
'/^ \* \x20 SEARCH \x20 ( .+ ) \r\n $ /ix';
1244 foreach ($this->
getUntagged($regex,
true) as $item)
1246 $result = preg_match_all(
'/\d+/', $item[1][1]);
1261 foreach ($flags as
$k => $item)
1263 if (!preg_match(sprintf(
'/ ^ \x5c? %s $ /ix', self::$atomRegex), $item))
1270 'APPEND "%s" (%s) "%26s" %s',
1273 $internaldate->
format(
'j-M-Y H:i:s O'),
1274 static::prepareString(
$data)
1285 $regex = sprintf(
'/^ OK \x20 \[ APPENDUID \x20 ( \d+ ) \x20 ( \d+ ) \] /ix', $this->
getTag());
1296 $folderTo = Emoji::decode($folderTo);
1304 if (preg_match(
'/ \x20 MOVE ( \x20 | \r\n ) /ix', $this->sessCapability))
1306 $result = $this->
move($ids, $folderFrom, $folderTo);
1313 $result = $this->
delete($ids, $folderFrom);
1319 public function move($ids, $folderFrom, $folderTo)
1388 public function seen($ids, $folder)
1416 public function delete($id, $mailboxName)
1451 private function expunge(&
$error)
1453 return $this->executeCommand(
'EXPUNGE',
$error);
1464 private function store($ids, $flags, &
$error, $isUid =
true, $isRemoveFlags =
false)
1466 $command = sprintf(
'STORE %s ', $this->prepareIdsParam($ids));
1467 $command .= $isRemoveFlags ?
'-' :
'+';
1468 $command = $command . sprintf(
'FLAGS (%s)', join(
' ', $flags));
1472 $command =
'UID ' . $command;
1475 return $this->executeCommand($command,
$error);
1488 $addFlags =
array();
1489 $delFlags =
array();
1490 foreach ($flags as
$name => $value)
1492 if (preg_match(sprintf(
'/ ^ \x5c? %s $ /ix', self::$atomRegex),
$name))
1496 $addFlags[] =
$name;
1500 $delFlags[] =
$name;
1510 if (!
$error && $delFlags)
1523 $this->
getUntagged(sprintf(
'/^ \* \x20 %u \x20 FETCH \x20 \( .+ \) \r\n $/isx', $id),
true);
1541 $section = mb_strtoupper($section);
1543 if (!in_array(mb_strtoupper($section),
array(
'HEADER',
'TEXT')))
1553 $response = $this->
fetch(
false, $mailbox, (
int) $id, sprintf(
'BODY.PEEK[%s]', $section),
$error);
1555 return $response[sprintf(
'BODY[%s]', $section)];
1564 if (is_array($dirs) && empty($dirs))
1581 if ($this->sessMailbox[
'exists'] > 0)
1586 $searchUntaggedRegex =
'/^ \* \x20 SEARCH \x20 ( .+ ) \r\n $ /ix';
1600 foreach ($this->
getUntagged($searchUntaggedRegex,
true) as $item)
1602 $matches = preg_match_all(
'/\d+/', $item[1][1]);
1609 'IMAP: invalid mailbox (search>exists) (%s:%s:%s:%u)',
1610 $this->options[
'host'], $this->options[
'login'], $mailbox, $this->sessMailbox[
'uidvalidity']
1618 $fetchUntaggedRegex =
'/^ \* \x20 ( \d+ ) \x20 FETCH \x20 \( ( .+ ) \) \r\n $/isx';
1632 foreach ($this->
getUntagged($fetchUntaggedRegex,
true) as $item)
1641 'IMAP: invalid mailbox (fetch>exists) (%s:%s:%s:%u)',
1642 $this->options[
'host'], $this->options[
'login'], $mailbox, $this->sessMailbox[
'uidvalidity']
1657 $length =
count($this->sessUntagged);
1658 for (
$i = 0;
$i < $length;
$i++)
1660 if (!preg_match($regex, $this->sessUntagged[
$i],
$matches))
1667 unset($this->sessUntagged[
$i]);
1670 if ($unset && !empty(
$result))
1671 $this->sessUntagged = array_values($this->sessUntagged);
1679 $this->sessCounter++;
1681 return sprintf(
'A%03u', $this->sessCounter);
1689 $chunks = explode(
"\x00", sprintf(
'%s %s', $this->
getTag(
true), $command));
1692 foreach ($chunks as $chunk)
1711 $error = Imap::ERR_COMMUNICATE;
1719 $error = Imap::ERR_EMPTY_RESPONSE;
1725 if (!preg_match(sprintf(
'/^ %s \x20 OK /ix', $this->
getTag()),
$response))
1727 if (preg_match(sprintf(
'/^ %s \x20 ( NO | BAD ) /ix', $this->
getTag()),
$response))
1728 $error = Imap::ERR_COMMAND_REJECTED;
1730 $error = Imap::ERR_BAD_SERVER;
1733 return preg_replace(sprintf(
'/^ %s \x20 /ix', $this->
getTag()),
'',
$response);
1739 if(($this->logLevel & self::LOG_LEVEL_WRITE))
1745 while (strlen(
$data) > 0 && !feof($this->stream))
1751 if (
false ===
$bytes || ++$fails >= 3)
1764 if (strlen(
$data) > 0)
1770 if($logData !==
null)
1782 while (
$bytes > 0 && !feof($this->stream))
1788 $meta = $this->options[
'timeout'] > 0
1789 ? stream_get_meta_data($this->stream)
1790 :
array(
'timed_out' =>
false);
1795 if ($meta[
'timed_out'])
1812 while (!feof($this->stream))
1814 $buffer = @fgets($this->stream, 4096);
1818 $meta = $this->options[
'timeout'] > 0
1819 ? stream_get_meta_data($this->stream)
1820 :
array(
'timed_out' =>
false);
1824 $eolRegex =
'/ (?<literal> \{ (?<bytes> \d+ ) \} )? \r\n $ /x';
1825 if (preg_match($eolRegex, $line,
$matches))
1830 if ($meta[
'timed_out'])
1834 if (
$data ===
false)
1840 if ($meta[
'timed_out'])
1844 if (!preg_match(
'/\r\n$/', $line,
$matches))
1850 if(($this->logLevel & self::LOG_LEVEL_READ))
1863 if ($line ===
false)
1866 if (mb_strpos($line,
'*') === 0)
1867 $this->sessUntagged[] = $line;
1869 while (mb_strpos($line,
'*') === 0);
1871 if (
'select' == $this->sessState)
1873 $regex =
'/^ \* \x20 ( \d+ ) \x20 EXISTS /ix';
1876 $this->sessMailbox[
'exists'] = $item[1][1];
1885 if (preg_match(
'/^[^\x00\x0a\x0d\x80-\xff]*$/',
$data))
1886 return sprintf(
'"%s"', static::escapeQuoted(
$data));
1888 return sprintf(
"{%u}\x00%s", strlen(
$data),
$data);
1906 $result = Encoding::convertEncoding(
$data, $this->options[
'encoding'],
'UTF7-IMAP');
1912 $result = Encoding::convertEncoding(
$result, $this->options[
'encoding'],
'UTF-8');
1915 $result = preg_replace_callback(
'/[\x00-\x1f\x7f-\xff]+/',
function(
$matches)
1919 $result = Encoding::convertEncoding(
$result,
'UTF-8',
'UTF-16BE');
1937 $result = Encoding::convertEncoding(
$data,
'UTF7-IMAP', $this->options[
'encoding']);
1943 $result = preg_replace_callback(
'/&([\x2b\x2c\x30-\x39\x41-\x5a\x61-\x7a]+)-/',
function(
$matches)
1949 $result = Encoding::convertEncoding(
$result,
'UTF-16BE',
'UTF-8');
1955 $result = Encoding::convertEncoding(
$result,
'UTF-8', $this->options[
'encoding']);
1961 private function prepareIdsParam($idsData)
1963 if (is_array($idsData))
1965 return implode(
',', array_map(
'intval', $idsData));
1969 return intval($idsData);
1976 $details = array_filter((
array) $details);
1987 $error .= sprintf(
' (IMAP: %s)', join(
': ', $details));
1989 $this->errors->setError(
new Main\
Error(
'IMAP', -1));
1990 foreach ($details as $item)
1992 $this->errors->setError(
new Main\
Error((
string) $item, -1));
2014 case self::ERR_CONNECT:
2015 return Loc::getMessage(
'MAIL_IMAP_ERR_CONNECT');
2016 case self::ERR_REJECTED:
2017 return Loc::getMessage(
'MAIL_IMAP_ERR_REJECTED');
2018 case self::ERR_COMMUNICATE:
2019 return Loc::getMessage(
'MAIL_IMAP_ERR_COMMUNICATE');
2020 case self::ERR_EMPTY_RESPONSE:
2021 return Loc::getMessage(
'MAIL_IMAP_ERR_EMPTY_RESPONSE');
2022 case self::ERR_BAD_SERVER:
2023 return Loc::getMessage(
'MAIL_IMAP_ERR_BAD_SERVER');
2024 case self::ERR_STARTTLS:
2025 return Loc::getMessage(
'MAIL_IMAP_ERR_STARTTLS');
2026 case self::ERR_COMMAND_REJECTED:
2027 return Loc::getMessage(
'MAIL_IMAP_ERR_COMMAND_REJECTED');
2028 case self::ERR_CAPABILITY:
2029 return Loc::getMessage(
'MAIL_IMAP_ERR_CAPABILITY');
2030 case self::ERR_AUTH:
2031 case self::ERR_SELECT:
2032 return Loc::getMessage(
'MAIL_IMAP_ERR_AUTH');
2033 case self::ERR_AUTH_MECH:
2034 return Loc::getMessage(
'MAIL_IMAP_ERR_AUTH_MECH');
2035 case self::ERR_AUTH_OAUTH:
2036 return Loc::getMessage(
'MAIL_IMAP_ERR_AUTH_OAUTH');
2037 case self::ERR_LIST:
2038 return Loc::getMessage(
'MAIL_IMAP_ERR_LIST');
2039 case self::ERR_SEARCH:
2040 return Loc::getMessage(
'MAIL_IMAP_ERR_SEARCH');
2041 case self::ERR_FETCH:
2042 return Loc::getMessage(
'MAIL_IMAP_ERR_FETCH');
2043 case self::ERR_APPEND:
2044 return Loc::getMessage(
'MAIL_IMAP_ERR_APPEND');
2045 case self::ERR_STORE:
2046 return Loc::getMessage(
'MAIL_IMAP_ERR_STORE');
2049 return Loc::getMessage(
'MAIL_IMAP_ERR_DEFAULT');
2055 if($this->logPath <>
'')
2057 $fileName = $this->options[
"host"].
".".$this->options[
"login"].
".log";
2058 file_put_contents($this->logPath.
"/".
$fileName,
$data, FILE_APPEND);
listMailboxes($pattern, &$error, $flat=false)
getUIDsForSpecificDay($dirPath, $internalDate)
getNew($mailbox, $uidMin, $uidMax, &$error)
getUnseen($dirPath, &$error, $startInternalDate=null)
const ERR_COMMAND_REJECTED
getUntagged($regex, $unset=false)
moveMails($ids, $folderFrom, $folderTo)
static unescapeQuoted($data)
listMessages($mailbox, &$uidtoken, &$error)
errorMessage($errors, $details=null)
getUidRange($mailbox, &$error)
ensureEmpty($mailbox, &$error)
updateMessageFlags($mailbox, $id, $flags, &$error)
select($mailbox, &$error)
static escapeQuoted($data)
copyMailToFolder($ids, $mailboxName, $folder)
fetch($uid, $mailbox, $range, $select, &$error, $outputFormat='smart')
addMessage($mailbox, $data, &$error)
listex($reference, $pattern, &$error)
isExistsDir($mailbox, &$error)
searchByHeader($uid, $mailbox, array $header, &$error)
executeCommand($command, &$error)
static decodeError($code)
static prepareString($data)
append($mailbox, array $flags, \DateTime $internaldate, $data, &$error)
move($ids, $folderFrom, $folderTo)
examine($mailbox, &$error)
__construct($host, $port, $tls, $strict, $login, $password, $encoding=null)
getMessage($mailbox, $id, $section, &$error)
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
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</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."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
if(!Loader::includeModule('sale')) $pattern