500 Internal Server Error - PHP Notice - iconv(): Detected an illegal character in input string

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

Your problem
Running the dev version (DDEV) and I get this error when I try to edit an email. This results in GrapesJS dying making the message unrecoverable:

500 Internal Server Error - PHP Notice - iconv(): Detected an illegal character in input string

  • /html/app/bundles/CoreBundle/Helper/InputHelper.php:420 at
  • Mautic\CoreBundle\ErrorHandler\ErrorHandler → handleError ( 8, ‘PHP Notice - iconv(): Detected an illegal character in input string’, ‘/var/www/html/app/bundles/CoreBundle/Helper/InputHelper.php’, 420 )
  • /html/app/bundles/CoreBundle/Helper/InputHelper.php:420 at iconv ( ‘UTF-8’, ‘Windows-1252’, ' !mso <meta name="…

Can this error be caught, so it does not result in loss of work?

These errors are showing in the log:

mautic.CRITICAL: Uncaught PHP Exception ErrorException: “PHP Notice - iconv(): Detected an illegal character in input string” at /var/www/html/app/bundles/CoreBundle/Helper/InputHelper.php line 420 {“exception”:"[object] (ErrorException(code: 0): PHP Notice - iconv(): Detected an illegal character in input string at /var/www/html/app/bundles/CoreBundle/Helper/InputHelper.php:420)
[stacktrace]
#0 [internal function]: Mautic\CoreBundle\ErrorHandler\ErrorHandler->handleError(8, ‘PHP Notice - ic…’, ‘/var/www/html/a…’, 420)
#1 /var/www/html/app/bundles/CoreBundle/Helper/InputHelper.php(420): iconv(‘UTF-8’, ‘Windows-1252’, ‘<!doctype html>…’)

Steps I have tried to fix the problem:

Now I get it when I try to save an email built using my own custom theme.

I also see this error with other themes.

It seems it only happens with MJML templates. Not HTML.

Steps to reproduce (Mautic 5.0.3, PHP 8.2.17):

  1. Install an MJLM-based theme.
  2. Enable the grapesjs builder.
  3. Create a new email.
  4. Select the MJLM theme.
  5. Click “Builder”.
  6. Save the builder (checkmark button) and close it.
  7. Click “Save”.
  8. You should see the error.

Here’s an example of the error using Ricardo Freire’s Feedback theme:

I also get this error if I try to use emoticons in my emails :frowning:

Weirdly enough, it only seems to have when using the latest dev version on the 5.x branch. The 5.0.3 release I run on my VPS has no issue with emoticons in email content.