Why is my css in my twig template getting ignored when I apply it to a newsletter issue and then email that newsletter to myself?

gu flag

I have created a simplenews Newsletter issue called test1 newsletter.

Newsletter content

In the simplenews-newsletter-body--default.html.twig template file I use for the newsletter, I need to add some CSS styles. This is the file content.

{% apply inline_css %}
<div id="email" style="width:600px;margin: auto;background:white;">
  <!-- Header -->
  <table role="presentation" border="0" width="100%" cellspacing="0">
    <td bgcolor="#E2FFF8" align="center" style="color: black;">
      <h1 style="font-size: 52px; margin:0 0 20px 0; font-family:Avenir;"> {{ node.getTitle }}</h1>
{% endapply %}

When I go to my Drupal site to email myself the test1 newsletter (under the heading "Test email address"), I do receive the email, but it seems to ignore all the CSS styling I have used (and the <h1> tag).



This is how the email should look like.


How I can fix this issue?

I am using Drupal 9.4.7.

id flag
Can you confirm you are using simplenews with a supported mail system module? The module readme says it supports Mime mail module.
Shane avatar
gu flag
@cilefen I have the Swift Mailer module installed.

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.