500 internal error when I save and close the e-mail editor

Your software
My Mautic version is: 5.0.3
My PHP version is: 8.1
My Database type and version is: MariaDB

Your problem
My problem is:
When I click on the button “Save and close” of the e-mail editor a page with 500 internal error appear like this:

E bug? Or how can I fix this?

Thank you any help

Hi @emmanu

Please provide us with more details, such as all the steps you took, so that we can replicate and understand what caused the bug.



What do the logs say under /var/logs?

Hi @mzagmajster and @ricfreire
Thank you for your replies.

The steps I took are:

  1. Went to Channels > email > created a new email
  2. Choose the segment email
  3. Selected the template I wanted, for exemple Brienz and opened the builder drag and drop to edit my email.
  4. When I finished, I saved the email and closed the builder
  5. In the email setting, I clicked the “Save and close” button and this page 500 internal error appeared.

The log says

[2024-02-22T07:56:15.568696+00:00] mautic.CRITICAL: Uncaught PHP Exception Twig>

Sorry the log was incomplete:

[2024-02-22T07:56:15.568696+00:00] mautic.CRITICAL: Uncaught PHP Exception Twig\Error\RuntimeError: "An exception has been thrown during the rendering of a template ("Mautic\CoreBundle\Twig\Extension\ContentExtension::getCustomContent(): Argument #2 ($vars) must be of type array, bool given, called in /var/www/html/newsletter/var/tmp/twig/6f/6fccdec65d4eb4f8ce60c19b2ea0f04f.php on line 404")." at /var/www/html/newsletter/docroot/app/bundles/EmailBundle/Resources/views/Email/details.html.twig line 251 {"exception":"[object] (Twig\\Error\\RuntimeError(code: 0): An exception has been thrown during the rendering of a template (\"Mautic\\CoreBundle\\Twig\\Extension\\ContentExtension::getCustomContent(): Argument #2 ($vars) must be of type array, bool given, called in /var/www/html/newsletter/var/tmp/twig/6f/6fccdec65d4eb4f8ce60c19b2ea0f04f.php on line 404\"). at /var/www/html/newsletter/docroot/app/bundles/EmailBundle/Resources/views/Email/details.html.twig:251)\n[previous exception] [object] (TypeError(code: 0): Mautic\\CoreBundle\\Twig\\Extension\\ContentExtention::getCustomContent(): Argument #2 ($vars) must be of type array, bool given, called in /var/www/html/newsletter/var/tmp/twig/6f/6fccdec65d4eb4f8ce60c19b2ea0f04f.php on line 404 at /var/www/html/newsletter/docroot/app/bundles/CoreBundle/Twig/Extension/ContentExtension.php:33)"} {"hostname":"prod-usa-newsletter","pid":2084194}

Go and check if grapeJS plugin is enabled.

Then try to use another template. If the result is the same, try reinstalling the php vendor packages.

It could also just be a bug in the core, but i imagine in that case more people would have this issue.

Please report back on how it goes.

Hi @mzagmajster ,
the grapeJS plugin is enabled and I tried all the template, the result is the same.
I tried reinstall the vendor packages but I don’t know if it is right because nothing changed… same problem:

rm -rf vendor && composer install

Installation of php packages looks OK.

Then there might be an issue with the core or the template you are using, when I get a chance I might check it myself.

Thank you!

Hi, are you using emojies in your email content? If ao can you test after removing them?

Hi @joeyk,
I’m not using emojies

Hi, is this fresh install or upgraded from M4 ?

Hi, this is upgrade from 5.0.1. I followed this tutorial to install M5.0.1:


Than switched to composer with this tutorial:


Finally I upgrade to M5.0.3 with composer and followed this forum post because some dependencies where missing:


Ok. You installed npm, right?

Yes, I installed npm

A fresh install of M5.0.3 solved the problem. I wasn’t able to access the campain editor too. With the fresh install it’s all ok.

Reading from those tutorials and no surprise that the upgrade failed.

First tutorial is making the installation using the wrong user. But then recover by doing a “chown www-data:”

Same for the second one (and in your case, most likely the one that blew it all up).

What is missing in those How To is either adding ‘su -e www-data “cmd in the how to”’ or, in the case of the second How To, doing a “chown www-data: /var/www/html -R”

Failing to do so is creating root owned files which are write protected against www-data user. Thus generating a 500 when www-data tries to edit those files.

Thank you @marcus42!