Closed jaswrks closed 9 years ago
Oh, wow. When I moved from hooking into wp_mail
into phpmailer_init
I didn't set that back up. I was previously checking for Content-Type
headers, but checking for HTML tags might be better.
The templater class is now checking for PHPMailer's ContentType
variable. That should be good enough for now.
I see there are a few instances where PHPMailer sets this to multipart/alternative
also; when there is an AltBody
. I think relying upon that other class, which is subject to change in any WordPress update that might include a newer release of \PHPMailer
is going to be rough.
I'd suggesting a quick check like this against the message body itself.
$message_body = '.... whatever ... ';
if(stripos($message_body, '<!DOCTYPE') !== FALSE || stripos($message_body, '</html>') !== FALSE)
return $message_body; // Do not parse any further; this is already a full HTML doc.
Added this additional check.
Great!
In this method I'd suggest trying to detect the presence of an existing
<!DOCTYPE
or</html>
tag in the body of an email before applying filters. This way you won't parse an email which has already been fully formatted and perhaps includes its own header/footer, etc.https://github.com/websharks/mail-remix/blob/000000-dev/mail-remix/classes/templater.php#L51