Error when using plain text wrapper and inline css together

Created on 18 December 2023, about 1 year ago
Updated 21 January 2024, 11 months ago

Problem/Motivation

When the *all* policy is set to use html email with inline css, a policy targeting a specific sub type with the Wrap and convert adjustment set to 'plain text only', the following error is thrown:

 [error]  ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty in DOMDocument->loadHTML() (line 116 of /Users/loze/Sites/hsc-mig1/vendor/tijsverkoyen/css-to-inline-styles/src/CssToInlineStyles.php) #0 /Users/loze/Sites/hsc-mig1/vendor/tijsverkoyen/css-to-inline-styles/src/CssToInlineStyles.php(116): DOMDocument->loadHTML('')
#1 /Users/loze/Sites/hsc-mig1/vendor/tijsverkoyen/css-to-inline-styles/src/CssToInlineStyles.php(36): TijsVerkoyen\CssToInlineStyles\CssToInlineStyles->createDomDocumentFromHtml(NULL)
#2 /Users/loze/Sites/hsc-mig1/web/modules/contrib/symfony_mailer/src/Plugin/EmailAdjuster/InlineCssEmailAdjuster.php(99): TijsVerkoyen\CssToInlineStyles\CssToInlineStyles->convert(NULL, 'body{width:100%...')
#3 [internal function]: Drupal\symfony_mailer\Plugin\EmailAdjuster\InlineCssEmailAdjuster->postRender(Object(Drupal\symfony_mailer\Email))
#4 /Users/loze/Sites/hsc-mig1/web/modules/contrib/symfony_mailer/src/Email.php(490): call_user_func(Array, Object(Drupal\symfony_mailer\Email))
#5 /Users/loze/Sites/hsc-mig1/web/modules/contrib/symfony_mailer/src/Mailer.php(237): Drupal\symfony_mailer\Email->process()
#6 /Users/loze/Sites/hsc-mig1/web/modules/contrib/symfony_mailer/src/Mailer.php(149): Drupal\symfony_mailer\Mailer->doSend(Object(Drupal\symfony_mailer\Email))
#7 /Users/loze/Sites/hsc-mig1/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\symfony_mailer\Mailer->Drupal\symfony_mailer\{closure}()
#8 /Users/loze/Sites/hsc-mig1/web/modules/contrib/symfony_mailer/src/Mailer.php(158): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))

What Im trying to achieve is all my emails to be sent as html with inline css, except for one specific sub type, which I want to be plain text

Proposed resolution

If Wrap and Convert is set to plain text only, skip the inline css process that may be set on a parent policy.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇺🇸United States loze Los Angeles

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024