PHP Fatal error: Uncaught Error: Class ‘Emogrifier’ not found

If you suddenly have an error with WooCommerce Email Customizer and your error logs show this issue:

PHP Fatal error: Uncaught Error: Class ‘Emogrifier’ not found in /home/***/public_html/wp-content/plugins/woocommerce-email-control/ec-email-control.php:1068

then the problem occurred as a result of the latest WooCommerce plugin update.

And the solution is as simple as it gets. Edit the file public_html/wp-content/plugins/woocommerce-email-control/ec-email-control.php

Line 1068, replace:

$emogrifier = new Emogrifier( $content, $css );

with

$emogrifier = new \Pelago\Emogrifier( $content, $css );

Enjoy the fix 🙂

Update for 3.24

If you are getting an Internal Server Error after updating the Woocommerce Email Customizer plugin to 3.24, the solution is simple – just rename the folder:

/public_html/wp-content/plugins/woocommerce-email-control/includes/emogrifier

to

/public_html/wp-content/plugins/woocommerce-email-control/includes/Emogrifier

Notice the capital E vs the old lowercase e.

4 thoughts on “PHP Fatal error: Uncaught Error: Class ‘Emogrifier’ not found

  • April 20, 2019 at 9:45 pm
    Permalink

    The error log may also show this stack trace:

    #0 /public_html/wp-content/plugins/woocommerce-email-control/ec-email-control.php(1014): WC_Email_Control->ec_style_inline_for_old_wc('...') 
    #1 /public_html/wp-includes/class-wp-hook.php(286): WC_Email_Control->ec_style_inline('...') #2 /public_html/wp-includes/plugin.php(208): WP_Hook->apply_filters('...', Array) 
    #3 /public_html/wp-content/plugins/woocommerce-email-control/pages/ec-preview-page.php(190): apply_filters('woocommerce_mai...', '...') 
    #4 /public_html/wp-content/plugins/woocommerce-email-control/ec-email-control.php(562): require_once('/home/...') 
    #5 /public_html/wp-includes/class-wp-hook.php(286): WC_Email_Control->ec_render_preview_page('') 
    #6 /public_html/wp-includes in /public_html/wp-content/plugins/woocommerce-email-control/ec-email-control.php on line 1068

    Your solution is correct and fixes all errors.

    Reply
  • April 21, 2019 at 12:17 am
    Permalink

    This fix seems to work but what is that directory \Pelago\ referring to? There’s no folders called Pelago?

    Reply
  • July 6, 2019 at 2:16 pm
    Permalink

    Thanks. It fixed the error.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *