5

I am getting this error in Magento 2.3. Error occurs with every email sent. enter image description here

CSS inlining error: DOMXPath::query(): Invalid expression in selector >> .fotorama__wrap:not(.fotorama__wrap--toggle-arrows) .fotorama__fullscreen-icon << in /var/www/html/magento2/vendor/pelago/emogrifier/src/Emogrifier.php on line 502

I have tried this method:

adding this file in app/design/frontend/VendorTheme/default/web/css/email.less

@import 'source/lib/email/stand/_lib.less'; // Global lib
@import 'source/lib/email/stand/variables/_email.less'; // Global email variables

I have also tried adding

"pelago/emogrifier": "1.0.0 as 0.1.1" in composer.json
2
  • what is your php version ? May 2 '19 at 13:48
  • just downgrade the php version 7.3 to 7.2 every thing is working fine May 3 '19 at 6:22
6

I have got same error and solved as

Just copy these files:

vendor/magento/theme-frontend-blank/web/css/email.less
vendor/magento/theme-frontend-blank/web/css/email-inline.less

into:

 app/design/frontend/YOUR_VENDOR/YOUR_THEME/web/css/

and removed this line from both files '@import 'source/_theme.less'.

Cause by doing this we are separating theme css and email css.

Last run the following commands:

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
2
  • this solution not working so please help me @Rohit Kaushik Dec 30 '19 at 6:08
  • have you removed _theme.less from both files? /vendor/magento/theme-frontend-blank/web/css/email.less /vendor/magento/theme-frontend-blank/web/css/email-inline.less Jan 3 '20 at 8:08
2

Please do not use in your css code selectors with :not(), especially if after another selector follows to ':not' .This is necessary to aviod Еmogrifier errrors

2
  • I had this &:not(:first-child) { in less and got this error too Invalid expression in selector >> .email-items tbody dl dt:not(:first-child) . Not sure if there is any other way to write same css. Apr 7 at 6:08
  • 1
    just write styles for all elements '.email-items tbody dl dt' and then write styles for element '.email-items tbody dl dt:first-child' separately. it would be better Apr 8 at 7:18
0

I've managed to fix the issue, is not the best practice, but it works.

Go to Marketing > Email Templates and create a new template. Click on Load template and load Magento_Email > Header.

In the Template Content field remove this line:

{{inlinecss file="css/email-inline.css"}}

A better solution would be to fix the issue in the file above.

1
0

Another solution:

My PHP version: 7.2.32

composer require pelago/emogrifier:2.0.0

It was not working with pelago/emogrifier:2.2.0

Thanks,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.