• Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/integration/sender/mail/messagemail.php
  • Класс: Bitrix\Sender\Integration\Sender\Mail\MessageMail
  • Вызов: MessageMail::getMailBody
public function getMailBody()
{
	Loader::includeModule('fileman');

	$msg = $this->configuration->getOption('MESSAGE')->getValue();
	$template = $this->getTemplate();
	if (!$template)
	{
		return $this->removePhp($msg);
	}
	if (!isset($template['FIELDS']) || !$template['FIELDS']['MESSAGE']['ON_DEMAND'])
	{
		return $this->removePhp($msg);
	}

	$templateHtml = null;
	if (isset($template['FIELDS']) && isset($template['FIELDS']['MESSAGE']))
	{
		$templateHtml = $template['FIELDS']['MESSAGE']['VALUE'];
	}
	if (!$templateHtml && isset($template['HTML']))
	{
		$templateHtml = $template['HTML'];
	}
	if (!$templateHtml)
	{
		return $this->removePhp($msg);
	}

	$document = new Document;
	$document->loadHTML($templateHtml);

	try
	{
		if(!Block\Content\Engine::create($document)->setContent($msg)->fill())
		{
			return '';
		}
	}
	catch (SystemException $exception)
	{
		throw new Posting\StopException();
	}

	StyleInliner::inlineDocument($document);
	$msg = $document->saveHTML();
	unset($document);

	$msg = $this->removePhp($msg);
	$msgTmp = Block\Editor::replaceCharset($msg, '#SENDER_MAIL_CHARSET#', true);
	if ($msgTmp)
	{
		$msg = $msgTmp;
	}

	if (Option::get('sender', 'use_inliner_for_each_template_mail', 'N') != 'Y')
	{
		$this->configuration->set('BODY', $msg);
	}

	return $msg;
}