• Модуль: mail
  • Путь к файлу: ~/bitrix/modules/mail/classes/general/mail.php
  • Класс: CAllMailMessage
  • Вызов: CAllMailMessage::decodeMessageBody
static function decodeMessageBody($header, $body, $charset)
{
	$encoding = mb_strtolower($header->GetHeader('CONTENT-TRANSFER-ENCODING'));

	if ($encoding == 'base64')
		$body = base64_decode($body);
	elseif ($encoding == 'quoted-printable')
		$body = quoted_printable_decode($body);
	elseif ($encoding == 'x-uue')
		$body = CMailUtil::uue_decode($body);

	$content_type = mb_strtolower($header->content_type);
	if (empty($header->filename) && !empty($header->charset))
	{
		if (preg_match('/plain|html|text/', $content_type) && !preg_match('/x-vcard|csv/', $content_type))
		{
			$body = Emoji::encode($body);
			$body = CMailUtil::convertCharset($body, $header->charset, $charset);
		}
	}

	return array(
		'CONTENT-TYPE' => $content_type,
		'CONTENT-ID'   => $header->content_id,
		'BODY'         => $body,
		'FILENAME'     => $header->filename
	);
}