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

	if (!$this->authenticate($error))
		return false;
	if ($this->sessState == 'select' && $mailbox == $this->sessMailbox['name'])
		return $this->sessMailbox;

	$response = $this->executeCommand(sprintf(
		'SELECT "%s"', static::escapeQuoted($this->encodeUtf7Imap($mailbox))
	), $error);

	if ($error)
	{
		$error = $error == Imap::ERR_COMMAND_REJECTED ? null : $error;
		$error = $this->errorMessage(array(Imap::ERR_SELECT, $error), $response);

		return false;
	}

	$this->sessState = 'select';
	$this->sessMailbox = array(
		'name'        => $mailbox,
		'exists'      => null,
		'uidvalidity' => null,
	);

	$regex = '/^ * x20 ( d+ ) x20 EXISTS /ix';
	foreach ($this->getUntagged($regex, true) as $item)
		$this->sessMailbox['exists'] = $item[1][1];

	$regex = '/^ * x20 OK x20 [ UIDVALIDITY x20 ( d+ ) ] /ix';
	foreach ($this->getUntagged($regex, true) as $item)
		$this->sessMailbox['uidvalidity'] = $item[1][1];

	$regex = sprintf(
		'/^ * x20 OK x20 [ PERMANENTFLAGS x20 ( ( ( x5c? %1$s | x5c * ) ( x20 (?2) )* )? ) ] /ix',
		self::$atomRegex
	);
	foreach ($this->getUntagged($regex, true) as $item)
	{
		$this->sessMailbox['permanentflags'] = explode("x20", $item[1][1]);
	}

	if (!$this->capability($error))
		return false;

	return $this->sessMailbox;
}