- Модуль: mail
- Путь к файлу: ~/bitrix/modules/mail/classes/general/imap.php
- Класс: CMailImap
- Вызов: CMailImap::getUnseen
public function getUnseen()
{
$unseen = 0;
$tag = $this->sendCommand("SELECT "INBOX"rn");
$response = $this->readResponse($tag);
if (mb_strpos($response, $tag.' OK') === false)
throw new Exception(GetMessage('MAIL_IMAP_ERR_BAD_SERVER'));
$tag = $this->sendCommand("SEARCH UNSEENrn");
$response = $this->readResponse($tag);
if (mb_strpos($response, $tag.' OK') === false)
throw new Exception(GetMessage('MAIL_IMAP_ERR_BAD_SERVER'));
if (preg_match('/* SEARCH( [0-9 ]*)?/i', $response, $matches))
{
if (isset($matches[1]))
$unseen = count(preg_split('/s+/', $matches[1], null, PREG_SPLIT_NO_EMPTY));
}
return $unseen;
}