allow starttls and smtps for mailing

This commit is contained in:
Bence Pőcze 2024-10-19 22:44:51 +02:00
parent 66040d69db
commit ecec258a64
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D

View File

@ -44,8 +44,10 @@ class Mail
if (!empty($_ENV['MAIL_HOST'])) { if (!empty($_ENV['MAIL_HOST'])) {
$mailer->Mailer = 'smtp'; $mailer->Mailer = 'smtp';
$mailer->Host = $_ENV['MAIL_HOST']; $mailer->Host = $_ENV['MAIL_HOST'];
$mailer->Port = !empty($_ENV['MAIL_PORT']) ? $_ENV['MAIL_PORT'] : 25; $mailer->Port = !empty($_ENV['MAIL_PORT']) ? $_ENV['MAIL_PORT'] : 587;
$mailer->SMTPSecure = !empty($_ENV['MAIL_SECURE']) ? $_ENV['MAIL_SECURE'] : '';
$secureMaping = ['none' => '', 'starttls' => PHPMailer::ENCRYPTION_STARTTLS, 'smtps' => PHPMailer::ENCRYPTION_SMTPS];
$mailer->SMTPSecure = !empty($_ENV['MAIL_SECURE']) ? $secureMaping[$_ENV['MAIL_SECURE']] : '';
if (!empty($_ENV['MAIL_USER'])) { if (!empty($_ENV['MAIL_USER'])) {
$mailer->SMTPAuth = true; $mailer->SMTPAuth = true;