- Модуль: mail
- Путь к файлу: ~/bitrix/modules/mail/lib/imap.php
- Класс: BitrixMailImap
- Вызов: Imap::getNew
public function getNew($mailbox, $uidMin, $uidMax, &$error)
{
$error = null;
if (!($uidMin <= $uidMax))
{
return false;
}
if (!$this->select($mailbox, $error))
{
return false;
}
$new = 0;
if (!($this->sessMailbox['exists'] > 0))
{
return $new;
}
if ($uidMax < 1)
{
return $this->sessMailbox['exists'];
}
$range = $this->getUidRange($mailbox, $error);
if (empty($range))
{
return false;
}
[$min, $max] = $range;
$searches = array();
if ($uidMin > 1 && $uidMin > $min)
{
$searches[] = sprintf('%u:%u', $min, $uidMin - 1);
}
if ($uidMax > 0 && $uidMax < $max)
{
$searches[] = sprintf('%u:%u', $uidMax + 1, $max);
}
if (!empty($searches))
{
$response = $this->executeCommand(sprintf('SEARCH UID %s', join(',', $searches)), $error);
if ($error)
{
$error = $error == Imap::ERR_COMMAND_REJECTED ? null : $error;
$error = $this->errorMessage(array(Imap::ERR_SEARCH, $error), $response);
return false;
}
$regex = '/^ * x20 SEARCH x20 ( .+ ) rn $ /ix';
foreach ($this->getUntagged($regex, true) as $item)
{
$new = preg_match_all('/d+/', $item[1][1]);
}
}
return $new;
}