- last update
over 1 year ago 1 pass
It looks like it is currently not possible to use HTML markup within the body field of an email, unless you are using the Mime Mail module.
This issue is introduced in the format() function of the HTMLMailSystem Plugin. (src/Plugin/Mail/HTMLMailSystem.php)
You can see in the below snippet that the message body is getting converted to Plain text, and all HTML tags are stripped.
// Collapse the message body array.
if ($this->configVariables->get('htmlmail_use_mime_mail')) {
$body = $this->formatMailMime($message);
$plain = $message['MailMIME']->getTXTBody();
}
else {
// Collapse the message body array.
if (is_array($message['body'])) {
// Join the body array into one string.
$message['body'] = implode("$eol$eol", $message['body']);
// Convert any HTML to plain-text.
$message['body'] = MailFormatHelper::htmlToText($message['body']);
// Wrap the mail body for sending.
$message['body'] = MailFormatHelper::wrapMail($message['body']);
}
This may have been added intentionally as a security best practice, but in the Drupal 7 module, this behavior was not present and you could add HTML directly to your message body.
I'm attaching a patch which removes this behavior, in case anyone else is encountering problems with it.
But there might be a more appropriate way to allow for this functionality and still have some level of sanitization for security purposes.
Needs review
3.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.