• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/mail/smtp/mailer.php
  • Класс: BitrixMainMailSmtpMailer
  • Вызов: Mailer::prepareConfiguration
public function prepareConfiguration(Context $context): bool
{
	$this->configuration = $this->getActualConfiguration($context);

	$this->SMTPDebug = $this->configuration['debug'] ?? false;

	if ($this->SMTPDebug)
	{
		$configuration = $this->configuration;
		$this->Debugoutput = function ($logMessage) use ($configuration) {
			$logger = new FileLogger(
				$configuration['logFile'] ?? (($_SERVER['DOCUMENT_ROOT'] ?? __DIR__) . '/mailer.log')
			);
			$logger->info($logMessage);
		};
	}
	$this->isSMTP();

	$this->SMTPAuth = (bool)$this->configuration['password'];
	$this->prepareOauthConfiguration();

	if (
		!$this->configuration['host']
		|| !$this->configuration['login']
	)
	{
		return false;
	}

	$this->From = $this->configuration['from'];
	$this->Host = $this->configuration['host'];
	$this->Username = $this->configuration['login'];
	$this->Password = $this->configuration['password'] ?? '';
	$this->Port = $this->configuration['port'] ?? 465;

	if (
		'smtps' === $this->configuration['encryption_type']
		|| ('smtp' !== $this->configuration['encryption_type'] && 465 === $this->port))
	{
		$this->SMTPSecure = $this->Port == 465 ? PHPMailer::ENCRYPTION_SMTPS : PHPMailer::ENCRYPTION_STARTTLS;
	}

	$this->Timeout = $this->configuration['connection_timeout'] ?? 30;

	return true;
}