Skip to content

Commit

Permalink
better plain text emails
Browse files Browse the repository at this point in the history
  • Loading branch information
JanST123 authored Jun 24, 2019
1 parent 2d92510 commit f1b208a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,19 @@ public static function send(string $to, string $subject, string $body, array $ad
);

if ($isHtml) {
$tmp = imap_8bit(nl2br($body));
$tmp = imap_8bit(
preg_replace('/^\h+/m', '',
html_entity_decode(
strip_tags(
preg_replace('/^\s*(<[^>]+>\s*)+\r?\n/m', '', $body)
)
)
)
);

$tmpHTML = $nl2brforHTML ? imap_8bit(nl2br($body)) : imap_8bit($body);
$body = "This is a MIME encoded message.";
$body.="\r\n\r\n--" . $boundary ."\r\nContent-Type: text/plain; charset=" . self::$charset . "\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n" . strip_tags($tmp);
$body.="\r\n\r\n--" . $boundary ."\r\nContent-Type: text/plain; charset=" . self::$charset . "\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n" . $tmp;
$body.="\r\n\r\n--" . $boundary ."\r\nContent-Type: text/html; charset=" . self::$charset . "\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n" . $tmpHTML;
$body.="\r\n\r\n--" . $boundary ."--";
}
Expand Down

0 comments on commit f1b208a

Please sign in to comment.