diff --git a/src/HazzelForms/HazzelForm.php b/src/HazzelForms/HazzelForm.php index ffabb43..5579b76 100644 --- a/src/HazzelForms/HazzelForm.php +++ b/src/HazzelForms/HazzelForm.php @@ -437,16 +437,16 @@ private function setToken() { * @throws Exception */ public function sendMail($to, $from, $replyTo = '', $senderName = 'HazzelForms', $subject = 'New HazzelForms Message', $template = 'basic') { - if (empty($replyTo)) { - $replyTo = $from; - } if ($this->mailer != null) { // use PHPMailer instance and override default settings - $this->mailer->isHTML(true); - $this->mailer->addAddress($to); $this->mailer->setFrom($from, $senderName); - $this->mailer->addReplyTo($replyTo); + $this->mailer->addAddress($to); + if(!empty($replyTo)){ + $this->mailer->addReplyTo($replyTo); + } + + $this->mailer->isHTML(true); $this->mailer->CharSet = 'UTF-8'; $this->mailer->Subject = $subject; $this->mailer->AltBody = $subject; diff --git a/src/HazzelForms/LegacyMailer.php b/src/HazzelForms/LegacyMailer.php index a828afe..4d8c49e 100644 --- a/src/HazzelForms/LegacyMailer.php +++ b/src/HazzelForms/LegacyMailer.php @@ -8,9 +8,6 @@ class LegacyMailer { protected $to; - protected $from; - protected $replyTo; - protected $senderName; protected $subject; protected $headers = []; protected $message = ''; @@ -23,9 +20,6 @@ class LegacyMailer public function __construct($to, $from, $replyTo, $senderName, $subject, $template, $lang) { $this->to = $to; - $this->from = $from; - $this->replyTo = $replyTo; - $this->senderName = $senderName; $this->subject = $subject; $this->lang = $lang; @@ -38,7 +32,9 @@ public function __construct($to, $from, $replyTo, $senderName, $subject, $templa // define headers $this->headers[] = "From: $senderName" . " <" . $from . ">"; - $this->headers[] = "Reply-To: " . $replyTo; + if(!empty($replyTo)){ + $this->headers[] = "Reply-To: " . $replyTo; + } $this->headers[] = "MIME-Version: 1.0"; $this->headers[] = "Content-Type: multipart/mixed; boundary=\"{$this->mimeBoundary}\""; $this->returnPath = "-f" . $from;