How do you apply CSS when you use swift mailer and mimemail? (in Drupal 9 webform’s email body)

I am using the webform’s email handler to send the submitted data (with swift mailer and mimemail). I did use inline CSS in both email body and PDF attachment but it just would not apply CSS in email while it renders perfectly in pdf.

 <p>[webform_submission:webform]</p>  <table style="border-collapse: collapse; border: 1px solid rgba(5, 138, 222, 0.67); empty-cells: show; margin: 1%; width: 100%; table-layout: auto;">     <tr>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">MAKE CHECKS PAYABLE TO:</th>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">SPECIAL HANDLING (CHECK ONE)</th>     </tr>     <tr>         <td>[webform_submission:values:make_checks_payable_to_]</td>         <td rowspan="2">[webform_submission:values:special_holding]</td>     </tr>     <tr>         <td>[webform_submission:values:address]</td>     </tr> </table> <br> <table style="border-collapse: collapse; border: 1px solid rgba(5, 138, 222, 0.67); empty-cells: show; margin: 1%; width: 100%; table-layout: auto;">     <tr>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">REQUEST BY</th>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">TODAY'S DATE</th>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;" colspan="2">DUE DATE</th>     </tr>     <tr>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;">[webform_submission:values:requested_by_01_requested_by_2]</td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;">[webform_submission:values:requested_by_01_today_s_date]</td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;" colspan="2">[webform_submission:values:requested_by_01_due_date]</td>     </tr>     <tr>         <td style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">REQUEST CURRENCY</td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;">[webform_submission:values:currency_rate_01_request_currency]</td>         <td style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">EXCHANGE RATE</td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;">[webform_submission:values:currency_rate_01_exchange_rate]</td>     </tr> </table> <br>  <table style="border-collapse: collapse; border: 1px solid rgba(5, 138, 222, 0.67); empty-cells: show; margin: 1%; width: 100%; table-layout: auto;">     <tr>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">QTY</th>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">PURPOSE</th>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">ACCOUNT CODE</th>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">TOTAL PRICE</th>     </tr>      {% for my_item in data.item %}     <tr>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;">{{my_item.qty}}</td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;">{{my_item.purpose}}</td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;">{{my_item.acct_num}}</td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;">{{'$ ' ~ my_item.total}}</td>     </tr>     {% endfor %}     <tr>         <td colspan="3" style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">SUBTOTAL</td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;">[webform_submission:values:balance_due_01_sub_total]</td>     </tr> </table>  <table style="border-collapse: collapse; border: 1px solid rgba(5, 138, 222, 0.67); empty-cells: show; margin: 1%; width: 100%; table-layout: auto;">     <tr>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">AUTHORIZED PURCHASER</th>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">DIRECTOR APPROVAL</th>     </tr>     <tr>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;" height="100"></td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;" height="100"></td>     </tr>     <tr>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">ACCT APPROVAL</th>         <th style="background-color: rgba(143, 220, 242, 0.67);         border: 1px solid rgba(5, 138, 222, 0.67);         border-left: 1px solid rgba(5, 138, 222, 0.67);         border-bottom: 1px solid rgba(5, 138, 222, 0.67);         color: #000000;         text-align: center;         font-weight: bold;         vertical-align: middle;         padding: .75em .5em;">EXEC APPROVAL</th>     </tr>     <tr>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;" height="100"></td>         <td style="text-align: right;         border: 1px solid rgba(5, 138, 222, 0.67);         vertical-align: middle;         padding: .75em .5em;" height="100"></td>     </tr> 

Excuse my long code but I had to do it this way instead since only inline CSS would be rendered (yet it still wouldn’t)

enter image description here enter image description here

In case if the Plain Text for the Text format needs to be changed, I can’t because it’s the only option given.

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

How do you apply CSS when you use swift mailer and mimemail? (in Drupal 9 webform’s email body)

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.