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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

loze created an issue. See original summary.

loze’s picture

Issue summary: View changes
adamps’s picture

THanks for the report. Here is my suggestion for a fix: make InlineCssEmailAdjuster skip processing if the HTML body is empty.

loze’s picture

Version: 1.4.0 » 1.x-dev

loze’s picture

Status: Active » Needs review
adamps’s picture

Status: Needs review » Needs work

Great thanks please can you fix the coding standards?

 86 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    |       |     (Drupal.ControlStructures.ControlSignature.SpaceAfterKeyword)

sourabhjain made their first commit to this issue’s fork.

sourabhjain’s picture

Status: Needs work » Needs review

  • AdamPS committed d940461a on 1.x authored by loze
    Issue #3409368: Error when using plain text wrapper and inline css...
adamps’s picture

Status: Needs review » Fixed

Great thanks everyone

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.