If MailPoet breaks with Fatal error: Uncaught Error: Class 'DOMDocument' not found, your server is missing the PHP DOM extension (bundled in php-xml on most distros). MailPoet (and libraries it uses) rely on DOMDocument to parse HTML and templates. Here’s the quickest way to enable it, plus ways to verify the fix for both web (PHP‑FPM/Apache) and CLI.
MailPoet crashes with “Class ‘DOMDocument’ not found” after a host/PHP upgrade. How do I fix this without disabling MailPoet?
This error means PHP’s DOM extension isn’t loaded for the PHP runtime your site is using. Enable/install it, then restart PHP and verify. Steps below cover common setups.
phpinfo.php in your site root:
<?php phpinfo(); ?>
Load https://yoursite.com/phpinfo.php and search for “DOM”.
Important: delete this file after testing.
php -m | grep -i dom
If it prints “dom”, the CLI has it; if your site still errors, the web PHP (php-fpm/Apache) is missing it or using a different php.ini.
cPanel (Select PHP Version)
Ubuntu/Debian
sudo apt-get update
# If your PHP is 8.2, use php8.2-xml; for distro default, php-xml is fine
sudo apt-get install -y php-xml php8.2-xml
# Restart the handler your site uses:
sudo systemctl restart php8.2-fpm || sudo systemctl restart apache2
RHEL/CentOS/Alma/Rocky
sudo dnf install -y php-xml
sudo systemctl restart php-fpm || sudo systemctl restart httpd
Plesk
Windows / Local PHP
php.ini and ensure the line extension=dom (or extension=php_dom.dll on older PHP) is not commented.phpinfo.php page and confirm the DOM section exists.which php
php -i | grep "Loaded Configuration File"
# Create a temporary file in WP root and load it in the browser:
# <?php phpinfo(); ?> # Check "Loaded Configuration File" there too.
Make sure both environments load a php.ini that enables DOM.
DOMDocument is part of PHP’s DOM extension. Without it, any plugin that parses HTML/XML (MailPoet templates, inline CSS, etc.) will fatal as soon as it tries to instantiate new DOMDocument(). Installing/enabling php-xml loads DOM and resolves the crash.
Need help confirming the right PHP handler or enabling the module in your hosting panel? We can check your phpinfo and set this up for you.
WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!