- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/mail/smtp/config.php
- Класс: BitrixMainMailSmtpConfig
- Вызов: Config::check
public function check(&$error = null, MainErrorCollection &$errors = null)
{
$error = null;
$errors = null;
if (!$this->canCheck())
{
return null;
}
if (MainModuleManager::isModuleInstalled('bitrix24'))
{
// Private addresses can't be used in the cloud
$ip = MainWebIpAddress::createByName($this->host);
if ($ip->isPrivate())
{
$error = 'SMTP server address is invalid';
$errors = new MainErrorCollection([new MainError($error)]);
return false;
}
}
$client = new MailSmtp(
$this->host,
$this->port,
('smtps' === $this->protocol || ('smtp' !== $this->protocol && 465 === $this->port)),
true,
$this->login,
$this->password
);
if (method_exists($client, 'setIsOauth'))
{
$client->setIsOauth($this->getIsOauth());
}
if (!$client->authenticate($error))
{
$errors = $client->getErrors();
return false;
}
return true;
}