Skip to content

Commit

Permalink
bugfix: some spam filters blocked emails because of empty reply-to fi…
Browse files Browse the repository at this point in the history
…elds
  • Loading branch information
hazzeldorn committed Jul 18, 2024
1 parent 49be386 commit 7051226
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/HazzelForms/HazzelForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 3 additions & 7 deletions src/HazzelForms/LegacyMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
class LegacyMailer
{
protected $to;
protected $from;
protected $replyTo;
protected $senderName;
protected $subject;
protected $headers = [];
protected $message = '';
Expand All @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit 7051226

Please sign in to comment.