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

	try
	{
		$mailBody = $this->getMailBody();
	}
	catch (SystemException $exception)
	{
		$result = new Result();
		$result->addError(new Error($exception->getMessage()));

		return $result;
	}

	if (Integration\Bitrix24\Service::isCloud())
	{
		if ($mailBody && mb_strpos($mailBody, '#UNSUBSCRIBE_LINK#') === false)
		{
			$result = new Result();
			$result->addError(new Error(Loc::getMessage('SENDER_INTEGRATION_MAIL_MESSAGE_ERR_NO_UNSUB_LINK')));
		}

		if (
			$mailBody
			&& $configuration->getOption('APPROVE_CONFIRMATION')->getValue() === 'Y'
			&& !$configuration->getOption('APPROVE_CONFIRMATION_CONSENT')->getValue()
		)
		{
			$result = new Result();
			$result->addError(new Error(Loc::getMessage('SENDER_INTEGRATION_MAIL_MESSAGE_ERR_NO_APPROVE_CONFIRMATION_CONSENT')));

			return $result;
		}
	}
	parse_str(
		$this->configuration->getOption('LINK_PARAMS')->getValue(),
		$utmTags
	);

	$utm = [];
	foreach ($utmTags as $utmTag => $value)
	{
		$utm[] = [
			'CODE' => $utmTag,
			'VALUE' => $value
		];
	}

	//TODO: compare with allowed email list
	$emailFrom = $this->configuration->getOption('EMAIL_FROM')->getValue();
	$emailFrom = (new Mail\Address($emailFrom))->get();
	$this->configuration->getOption('EMAIL_FROM')->setValue($emailFrom);

	$trackMail = $this->configuration->getOption('TRACK_MAIL')->getValue();

	if (!$trackMail)
	{
		$this->configuration->getOption('TRACK_MAIL')->setValue('N');
	}
	return Entity\Message::create()
		->setCode($this->getCode())
		->setUtm($utm)
		->saveConfiguration($this->configuration);
}