• Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/integration/sender/mail/messagemail.php
  • Класс: Bitrix\Sender\Integration\Sender\Mail\MessageMail
  • Вызов: MessageMail::loadConfiguration
public function loadConfiguration($id = null)
{
	$this->setConfigurationOptions();
	Entity\Message::create()
		->setCode($this->getCode())
		->loadConfiguration($id, $this->configuration);


	// do not remove: increment ref count to closure for rewriting.
	$instance = $this;
	$this->closureRefCountFix = function () use (&$instance)
	{
		return $instance->getMailBody();
	};

	$trackMail = $this->configuration->getOption('TRACK_MAIL')->getValue();
	if (is_null($trackMail))
	{
		$this->configuration->getOption('TRACK_MAIL')->setValue(Option::get('sender', 'track_mails'));
	}

	$optionLinkParams = $this->configuration->getOption('LINK_PARAMS');
	if ($optionLinkParams)
	{
		$optionLinkParams->setView(
			function () use ($id, $optionLinkParams)
			{
				ob_start();
				$GLOBALS['APPLICATION']->IncludeComponent(
					'bitrix:sender.mail.link.editor', '',
					array(
						"INPUT_NAME" => "%INPUT_NAME%",
						"VALUE" => $optionLinkParams->getValue(),
						"USE_DEFAULT" => (
							!$optionLinkParams->getValue()
							&&
							!$id
							&&
							!Application::getInstance()->getContext()->getRequest()->isPost()
						),
						"PLACEHOLDERS" => array(
							array(
								"code" => "campaign",
								"inputName" => "%INPUT_NAME_SUBJECT%"
							)
						),
						"DEFAULT_VALUE" => Option::get(
							'sender',
							'mail_utm',
							'utm_source=newsletter&utm_medium=mail&utm_campaign=%campaign%'
						)
					)
				);
				return ob_get_clean();
			}
		);
	}

	$optionFrom = $this->configuration->getOption('EMAIL_FROM');
	if ($optionFrom)
	{
		$optionFrom->setView(
			function () use ($optionFrom)
			{
				ob_start();
				$GLOBALS['APPLICATION']->IncludeComponent(
					'bitrix:sender.mail.sender', '',
					array(
						"INPUT_NAME" => "%INPUT_NAME%",
						"VALUE" => $optionFrom->getValue()
					)
				);
				return ob_get_clean();
			}
		);
	}

	$this->configuration->set('BODY', $this->closureRefCountFix);

	$mailHeaders = array('Precedence' => 'bulk');
	$mailHeaders = self::fillHeadersByOptionHeaders($mailHeaders);
	$this->configuration->set('HEADERS', $mailHeaders);
	TimeLimiter::prepareMessageConfigurationView($this->configuration);

	return $this->configuration;
}