Hello All,

We are deploying our first Drupal 8 site. While in development, we seem to have run into a minor issue, which I can not find any documentation on.

It does not seem that there is ANY WAY to have HTML properly formatted within an outbound email.

Is there a tutorial, or how-to on this somewhere? Am I the ONLY one struggling with having the outbound emails be in HTML?

CommentFileSizeAuthor
#6 patch_1.txt738 bytesbranimirpetkov
#5 patch.txt647 bytesbranimirpetkov
#4 patch.txt648 bytesbranimirpetkov

Comments

ScottBaetz created an issue. See original summary.

robertoperuzzo’s picture

I have the same problem: I can't send HTML body email.

I've noticed a weird thing in SwiftMailer.php class at line 645:

// If $item is not marked safe then it will be escaped.
return $body instanceof MarkupInterface ? $body : Html::escape($body);

So I think my email body isn't "safe". So I wonder "How can I make it safe?".

Thanks.

dunebl’s picture

I confirm that I couldn't get formatted emails:
I can see that the emails are using my twig template,s but unfortunately most of html tags are removed (but does exist in the twig)
If I remember well this was working well few months ago... now I discover the problem

branimirpetkov’s picture

StatusFileSize
new648 bytes

Temporary patch for the issue at hand.

branimirpetkov’s picture

StatusFileSize
new647 bytes

Fixed the error about Self-closing XHTML tags are ignored.

branimirpetkov’s picture

StatusFileSize
new738 bytes

Added multiple tags support for different uses

taiger’s picture

The patch in #6 works but it seems like this module should be allowing and exposing filter formats for system emails at admin/config/people/accounts.

For now, using this patch allows html to be in the body of the email. Thanks!

alemadlei’s picture

I confirm that #6 works for me, though an ideal solution would be to allow picking the text format used for emails.

jeffschuler’s picture

In Message settings ( admin/config/swiftmailer/messages ), have you tried setting "Respect provided e-mail format"?

As that option's descriptive text suggests: "Unless your site somehow alters e-mails, enabling this setting will result in all e-mails to be sent as plain text as this is the content type Drupal by default will apply to all e-mails."

Also, see #3016912: Add a setting to apply a HTML filter about associating text format with mail format.

pranav45’s picture

Thanks @branimirpetkov,patch from #6 works for me too.

adamps’s picture

Title: Generating HTML emails (UPDATE PLEASE) » Generating HTML emails
Status: Active » Closed (duplicate)

This issue seems to be a mixture of

  • valid problems now covered in #3122389: Bugs with format conversion
  • some requests for exactly what #3122389 is trying to remove that this module won't fix
  • basic support requests, general discussion, and temporary patches.

Let's close it in favour of #3122389.