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

**URL:** <https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995>\
**Category:** Mautic 5 Install/Upgrade Support\
**Created:** [February 21, 2024, 3:43pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995 "2024-02-21T15:43:38Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [February 21, 2024, 3:43pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/1 "2024-02-21T15:43:38Z")

</div>

**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:

 ![print](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/5/51257be40db14647fdd4a9da9a4e512c18bb359d.jpeg)  
E bug? Or how can I fix this?

Thank you any help

---

<div class="post-metadata">

**Author:** ![ricfreire](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ricfreire/32/14973_2.png) [@ricfreire](https://forum.mautic.org/u/ricfreire)\
**Post date:** [February 21, 2024, 5:49pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/2 "2024-02-21T17:49:28Z")

</div>

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.

Thanks!

🙂

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [February 21, 2024, 6:09pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/3 "2024-02-21T18:09:06Z")

</div>

What do the logs say under /var/logs?

---

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [February 22, 2024, 8:05am UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/4 "2024-02-22T08:05:38Z")

</div>

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>`

---

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [February 22, 2024, 8:52am UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/5 "2024-02-22T08:52:58Z")

</div>

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}`

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [February 22, 2024, 6:22pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/6 "2024-02-22T18:22:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [February 23, 2024, 4:15pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/8 "2024-02-23T16:15:56Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [February 23, 2024, 5:33pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/9 "2024-02-23T17:33:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [February 23, 2024, 6:56pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/10 "2024-02-23T18:56:06Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [February 24, 2024, 9:59pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/11 "2024-02-24T21:59:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [February 25, 2024, 8:53am UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/12 "2024-02-25T08:53:31Z")

</div>

Hi @joeyk,  
I’m not using emojies

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [February 25, 2024, 9:15am UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/13 "2024-02-25T09:15:56Z")

</div>

Hi, is this fresh install or upgraded from M4 ?

---

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [February 25, 2024, 10:55am UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/14 "2024-02-25T10:55:49Z")

</div>

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

[https://mauteam.org/mautic/mautic-admins/mautic-5-installation-on-ubuntu-22-04-with-php-8-1-and-mariadb-11/](https://mauteam.org/mautic/mautic-admins/mautic-5-installation-on-ubuntu-22-04-with-php-8-1-and-mariadb-11/)

Than switched to composer with this tutorial:

[https://docs.mautic.org/en/5.x/getting\_started/switching\_composer.html#:~:text=Here%E2%80%99s%20the%20steps%20to%20follow%20to%20switch%20to,point%20to%20%2Fvar%2Fwww%2Fhtml%2Fdocroot%20instead%20of%20%2Fvar%2Fwww%2Fhtml%20Altri%20elementi](https://docs.mautic.org/en/5.x/getting_started/switching_composer.html#:~:text=Here%E2%80%99s%20the%20steps%20to%20follow%20to%20switch%20to,point%20to%20%2Fvar%2Fwww%2Fhtml%2Fdocroot%20instead%20of%20%2Fvar%2Fwww%2Fhtml%20Altri%20elementi)

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

[https://forum.mautic.org/t/4-4-10-5-0-1-fails-because-symfony-path-is-not-fount-in-parameterloader-php/30475/9](https://forum.mautic.org/t/4-4-10-5-0-1-fails-because-symfony-path-is-not-fount-in-parameterloader-php/30475/9)

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [February 25, 2024, 12:23pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/15 "2024-02-25T12:23:41Z")

</div>

Ok. You installed npm, right?

---

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [February 25, 2024, 7:58pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/16 "2024-02-25T19:58:02Z")

</div>

Yes, I installed npm

---

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [March 3, 2024, 9:17pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/17 "2024-03-03T21:17:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![marcus42](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@marcus42](https://forum.mautic.org/u/marcus42)\
**Post date:** [March 4, 2024, 1:54pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/18 "2024-03-04T13:54:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![emmanu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/emmanu/32/11151_2.png) [@emmanu](https://forum.mautic.org/u/emmanu)\
**Post date:** [March 4, 2024, 3:00pm UTC](https://forum.mautic.org/t/500-internal-error-when-i-save-and-close-the-e-mail-editor/30995/19 "2024-03-04T15:00:50Z")

</div>

Thank you @marcus42!
