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.
Comments
Comment #2
loze commentedComment #3
adamps commentedTHanks for the report. Here is my suggestion for a fix: make InlineCssEmailAdjuster skip processing if the HTML body is empty.
Comment #4
loze commentedComment #6
loze commentedComment #7
adamps commentedGreat thanks please can you fix the coding standards?
Comment #9
sourabhjainComment #11
adamps commentedGreat thanks everyone