From fbe047c877361faec4c26c6a45a652428c76a8ba Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sat, 25 Feb 2023 22:17:17 +0100 Subject: [PATCH] core sendmail fix --- core/core.php | 32 +++++++++++++++----------------- module/blog/blog.php | 4 +++- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/core/core.php b/core/core.php index 0b4ed358..7d141e6e 100644 --- a/core/core.php +++ b/core/core.php @@ -1108,36 +1108,34 @@ class common $mail->CharSet = 'UTF-8'; // Mail try { - // Paramètres SMTP + // Paramètres SMTP perso if ($this->getdata(['config', 'smtp', 'enable'])) { //$mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; $mail->isSMTP(); $mail->SMTPAutoTLS = false; $mail->Host = $this->getdata(['config', 'smtp', 'host']); $mail->Port = (int) $this->getdata(['config', 'smtp', 'port']); - if ($this->getData(['config', 'smtp', 'auth'])) { $mail->Username = $this->getData(['config', 'smtp', 'username']); $mail->Password = helper::decrypt($this->getData(['config', 'smtp', 'username']), $this->getData(['config', 'smtp', 'password'])); $mail->SMTPAuth = $this->getData(['config', 'smtp', 'auth']); $mail->SMTPSecure = $this->getData(['config', 'smtp', 'secure']); - if (is_null($replyTo)) { - $mail->addReplyTo($this->getData(['config', 'smtp', 'username'])); - } else { - $mail->addReplyTo($replyTo); - } - } - // Fin SMTP - } else { - $host = str_replace('www.', '', $_SERVER['HTTP_HOST']); - $from = $from ? $from : 'no-reply@' . $host; - $mail->setFrom($from, $this->getData(['locale', 'title'])); - if (is_null($replyTo)) { - $mail->addReplyTo('no-reply@' . $host, $this->getData(['locale', 'title'])); - } else { - $mail->addReplyTo($replyTo); } } + + // Expéditeur + $host = str_replace('www.', '', $_SERVER['HTTP_HOST']); + $from = $from ? $from : 'no-reply@' . $host; + $mail->setFrom($from, $this->getData(['locale', 'title'])); + + // répondre à + if (is_null($replyTo)) { + $mail->addReplyTo($from, $this->getData(['locale', 'title'])); + } else { + $mail->addReplyTo($replyTo); + } + + // Destinataires if (is_array($to)) { foreach ($to as $userMail) { $mail->addAddress($userMail); diff --git a/module/blog/blog.php b/module/blog/blog.php index e4e8972c..7845d6e9 100755 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -773,7 +773,9 @@ class blog extends common 'Nouveau commentaire déposé', 'Bonjour' . ' ' . $firstname[$key] . ' ' . $lastname[$key] . ',

' . 'L\'article ' . $this->getData(['module', $this->getUrl(0), 'posts', $this->getUrl(1), 'title']) . ' a reçu un nouveau commentaire.

', - '' + null, + $this->getData(['config', 'smtp', 'from']), + ); if ($sent === false) $error++;