From 6fd392bc15b79dba8d381d8bddead71b72db4655 Mon Sep 17 00:00:00 2001 From: Bernard Spil Date: Wed, 13 May 2020 23:30:47 +0200 Subject: [PATCH] Fix SMTP for servers that don't need auth (#783) Currently this fails against servers that don't need or support AUTH but rely on other means to allow relaying email. --- server/libs/MailSender.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/libs/MailSender.php b/server/libs/MailSender.php index 67cedd7b..5802ffb9 100755 --- a/server/libs/MailSender.php +++ b/server/libs/MailSender.php @@ -66,10 +66,12 @@ class MailSender { $this->mailerInstance->CharSet = 'UTF-8'; $this->mailerInstance->isSMTP(); - $this->mailerInstance->SMTPAuth = true; $this->mailerInstance->Host = $this->mailOptions['smtp-host']; - $this->mailerInstance->Username = $this->mailOptions['smtp-user']; - $this->mailerInstance->Password = $this->mailOptions['smtp-pass']; + if($this->mailerInstance->Username !== '') { + $this->mailerInstance->SMTPAuth = true; + $this->mailerInstance->Username = $this->mailOptions['smtp-user']; + $this->mailerInstance->Password = $this->mailOptions['smtp-pass']; + } $this->mailerInstance->Timeout = 10; $this->mailerInstance->SMTPOptions = [ 'ssl' => [