From 65148af4542ab04d04b8a261ea7e4a565ffe9819 Mon Sep 17 00:00:00 2001 From: Thibault Dockx <thibault.dockx@fusiondirectory.org> Date: Thu, 12 Sep 2024 16:12:11 +0100 Subject: [PATCH] :sparkles: Feat(Integrator) - mailLib is now allowing unsecure mail and non authentication to server relay Mail relay server can be un-authenticated and self sign certified. --- src/FusionDirectory/Mail/MailLib.php | 35 +++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/FusionDirectory/Mail/MailLib.php b/src/FusionDirectory/Mail/MailLib.php index e25450b..0293e8b 100644 --- a/src/FusionDirectory/Mail/MailLib.php +++ b/src/FusionDirectory/Mail/MailLib.php @@ -55,12 +55,35 @@ class MailLib * $this->mail->Helo = '['.$_SERVER['SERVER_ADDR'].']'; */ - $this->mail->SMTPAuth = TRUE; - $this->mail->Username = $_ENV["MAIL_USER"]; - $this->mail->Password = $_ENV["MAIL_PASS"]; - $this->mail->SMTPSecure = $_ENV["MAIL_SEC"]; - $this->mail->Port = $_ENV["MAIL_PORT"]; - $this->mail->AuthType = 'LOGIN'; + + // Authentication mechanism + if ($_ENV["MAIL_AUTH"] == "TRUE") { + $this->mail->SMTPAuth = TRUE; + $this->mail->Username = $_ENV["MAIL_USER"]; + $this->mail->Password = $_ENV["MAIL_PASS"]; + } else { + $this->mail->SMTPAuth = FALSE; + } + + + // Security logic about SSL certificate potential verification. + if ($_ENV["MAIL_SEC_VERIFY"] == "TRUE") { + $this->mail->SMTPSecure = $_ENV["MAIL_SEC"]; + $this->mail->AuthType = 'LOGIN'; + } else { + // Disable SSL certificate verification + $this->mail->SMTPOptions = array( + 'ssl' => array( + 'verify_peer' => FALSE, + 'verify_peer_name' => FALSE, + 'allow_self_signed' => TRUE + ) + ); + } + + + $this->mail->Port = $_ENV["MAIL_PORT"]; + if (!empty($this->attachments)) { foreach ($this->attachments as $attachment) { -- GitLab