Skip to content

Commit

Permalink
Fix for Plain Text emails losing their line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
eSilverStrike committed Jan 19, 2022
1 parent 75b7bcc commit 1eab5f2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions system/classes/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Geeklog;

use GLText;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

/**
* Class Mail
Expand Down Expand Up @@ -224,17 +224,19 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr
// Replace placeholders
self::replacePlaceHolders($address, $subject, $body);

$mail->Body = $body;
// Ready Plain Text version of email
// bug #430
$altbody = GLText::removeAllHTMLTagsAndAttributes($body);
// bug #1000
// Need to do this since htmLawed not only strips the tags it converts html special chars to entities which we do not want
$altbody = htmlspecialchars_decode($altbody, ENT_QUOTES);

if (!$html) {
// bug #430
$body = GLText::removeAllHTMLTagsAndAttributes($body);

// bug #1000
// Need to do this since htmLawed not only strips the tags it converts html special chars to entities which we do not want
$body = htmlspecialchars_decode($body, ENT_QUOTES);
$mail->AltBody = $body;
}
$mail->Body = $altbody;
} else {
$mail->Body = $body;
$mail->AltBody = $body; // Only include this for HTML emails
}

// Set subject
$mail->Subject = $subject;
Expand Down

0 comments on commit 1eab5f2

Please sign in to comment.