• Модуль: mail
  • Путь к файлу: ~/bitrix/modules/mail/lib/imap.php
  • Класс: BitrixMailImap
  • Вызов: Imap::getUnseen
public function getUnseen($dirPath, &$error, $startInternalDate = null)
{
	$error = null;

	if (!$this->select($dirPath, $error))
	{
		return false;
	}

	$unseen = 0;

	if (!($this->sessMailbox['exists'] > 0))
	{
		return $unseen;
	}

	$command = 'SEARCH UNSEEN';

	if(!is_null($startInternalDate))
	{
		$command .= (' SINCE '.$startInternalDate->format('j-M-Y'));
	}
	$response = $this->executeCommand($command, $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)
	{
		$unseen = preg_match_all('/d+/', $item[1][1]);
	}

	return $unseen;
}