mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
Fix for poorly formatted text emails derived from html tables.
This commit is contained in:
@@ -1333,6 +1333,8 @@ class e107Email extends PHPMailer
|
||||
$this->Body = $message;
|
||||
//print_a($message);
|
||||
$textMsg = str_replace("\n", "", $message);
|
||||
$textMsg = str_replace('</td>', "\t", $textMsg);
|
||||
$textMsg = str_replace("</tr>", "\n", $textMsg);
|
||||
$textMsg = str_replace(array('<br />', '<br>'), "\n", $textMsg); // Modified to make sure newlines carried through
|
||||
$textMsg = preg_replace('#^.*?<body.*?>#', '', $textMsg); // Knock off everything up to and including the body statement (if present)
|
||||
$textMsg = preg_replace('#</body.*?>.*$#', '', $textMsg); // Knock off everything after and including the </body> (if present)
|
||||
@@ -1355,7 +1357,7 @@ class e107Email extends PHPMailer
|
||||
$this->AltBody = 'To view this email message, enable HTML!' . "\n\n";
|
||||
}
|
||||
|
||||
return $this->Body;
|
||||
return $this->Body;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -83,12 +83,34 @@
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
public function testMsgHTML()
|
||||
{
|
||||
$html = "\n
|
||||
Hi <b>Joe</b><br />
|
||||
|
||||
Check out <a href='http://e107.org'>http://e107.org</a><br />
|
||||
<br />
|
||||
Thanks,<br />
|
||||
Admin<br />
|
||||
<br />
|
||||
<table>
|
||||
<tr>
|
||||
<td>Website:</td><td>https://e107.org</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Github:</td><td>https://github.com/e107inc/</td></tr>
|
||||
</table>";
|
||||
|
||||
|
||||
$this->eml->MsgHTML($html);
|
||||
|
||||
$result = json_encode($this->eml->AltBody);
|
||||
$expected = '"Hi Joe\\nCheck out http:\\/\\/e107.org\\n\\nThanks,\\nAdmin\\n\\nWebsite:\\thttps:\\/\\/e107.org\\t\\nGithub:\\thttps:\\/\\/github.com\\/e107inc\\/"';
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public function testSendEmail()
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user