From 953f9f06de0a33a0ec4ae61d1920ecb0596d55f3 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 28 Feb 2020 14:58:50 +0100 Subject: [PATCH] fix reply to email --- core/core.php | 4 ++-- module/form/form.php | 10 ++++++---- module/form/view/config/config.php | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/core.php b/core/core.php index 3df546bf..39f1a667 100644 --- a/core/core.php +++ b/core/core.php @@ -771,7 +771,7 @@ class common { * @param string $content Contenu * @return bool */ - public function sendMail($to, $subject, $content, $replyTo = '') { + public function sendMail($to, $subject, $content, $replyTo = null) { // Utilisation de PHPMailer version 6.0.6 //require_once "core/vendor/phpmailer/phpmailer.php"; //require_once "core/vendor/phpmailer/exception.php"; @@ -786,7 +786,7 @@ class common { $mail->CharSet = 'UTF-8'; $host = str_replace('www.', '', $_SERVER['HTTP_HOST']); $mail->setFrom('no-reply@' . $host, $this->getData(['config', 'title'])); - if (empty($replyTo)) { + if (is_null($replyTo)) { $mail->addReplyTo('no-reply@' . $host, $this->getData(['config', 'title'])); } else { $mail->addReplyTo($replyTo); diff --git a/module/form/form.php b/module/form/form.php index 4e3e0b7a..19da4685 100644 --- a/module/form/form.php +++ b/module/form/form.php @@ -296,7 +296,7 @@ class form extends common { // Préparation le contenu du mail $data = []; $content = ''; - $replyTo = ''; + $replyTo = null; foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input) { // Filtre la valeur switch($input['type']) { @@ -309,15 +309,17 @@ class form extends common { case self::TYPE_DATETIME: $filter = helper::FILTER_STRING_SHORT; // Mettre TYPE_DATETIME pour récupérer un TIMESTAMP break; - CASE self::TYPE_CHECKBOX: + case self::TYPE_CHECKBOX: $filter = helper::FILTER_BOOLEAN; break; default: $filter = helper::FILTER_STRING_SHORT; } $value = $this->getInput('formInput[' . $index . ']', $filter, $input['required']) === true ? 'X' : $this->getInput('formInput[' . $index . ']', $filter, $input['required']); - // Champ reply ajouté au mail - if ($this->getData(['module', $this->getUrl(0), 'config', 'replyto']) === true && $filter === helper::FILTER_MAIL) { + // premier chalmp email ajouté au mail en reply si option active + if ($this->getData(['module', $this->getUrl(0), 'config', 'replyto']) === true && + $input['type'] === 'mail' && + $replyTo !== null) { $replyTo = $value; } // Préparation des données pour la création dans la base diff --git a/module/form/view/config/config.php b/module/form/view/config/config.php index 00cfc33e..47ada59d 100644 --- a/module/form/view/config/config.php +++ b/module/form/view/config/config.php @@ -121,7 +121,7 @@
- (bool) $this->getData(['module', $this->getUrl(0), 'config', 'replyto']), 'help' => 'Cette option permet de réponse drectement à l\'expéditeur du message si celui-ci a indiqué un email valide.' ]); ?>