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

	if ($this->sendData(sprintf("%srn", $data)) === false)
	{
		$error = Imap::ERR_COMMUNICATE;
		return false;
	}

	$response = $this->readResponse();

	if ($response === false)
	{
		$error = Imap::ERR_EMPTY_RESPONSE;
		return false;
	}

	$response = trim($response);

	if (!preg_match(sprintf('/^ %s x20 OK /ix', $this->getTag()), $response))
	{
		if (preg_match(sprintf('/^ %s x20 ( NO | BAD ) /ix', $this->getTag()), $response))
			$error = Imap::ERR_COMMAND_REJECTED;
		else
			$error = Imap::ERR_BAD_SERVER;
	}

	return preg_replace(sprintf('/^ %s x20 /ix', $this->getTag()), '', $response);
}