diff --git a/src/FusionDirectory/Mail/MailLib.php b/src/FusionDirectory/Mail/MailLib.php index e25450b280b03c3a804010e174a7d0c21916fdbe..b6ab1e13d85b1515ef8649a832bb0d0b6a485c66 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 = [ + 'ssl' => [ + '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) {