Troubleshooting Mautic 5.0.3 Upgrade: Sparkpost Plugin Issues and Character Escaping Errors

Your software
My Mautic version is: 5.0.3
My PHP version is: 8.0.30
My Database type and version is: MySQL 8.0.33

Your problem
My problem is:

I recently upgraded from Mautic 4.4.10 to 5.0.3 and am attempting to use the Sparkpost plugin (GitHub - ts-navghane/sparkpost-plugin: Sparkpost Mailer Plugin for Mautic). I ran into a number of issues the first being a fatal php error thrown while running cache:clear (and presumably other console commands). I managed to resolve this by running “composer install --no-dev --optimize-autoloader” (I have no idea if this has caused other issues), after which the plugin seems to be installed. However, trying to send a test email I keep receiving the error “[{“message”:“No sending domain specified”,“code”:“7001”}]” even though my “Email address to send mail from” is set correctly.

Further more, and likely unrelated, as part of my sparkpost configuration I have custom email headers set and everytime I save the config my custom email header values are character escaped malforming my configuration. For example my json string which is supposed to take the form {{“options”: { "… is being escaped everytime I save the config… {{"options … and just gets longer and longer.

chrome_2024-02-16_06-20-18

These errors are showing in the log:

php.CRITICAL: Fatal Error: During class fetch: Uncaught ReflectionException: Class “Liip\TestFixturesBundle\Test\FixturesTrait” not found while loading “MauticPlugin\SparkpostBundle\Tests\Functional\EventSubscriber\CallbackSubscriberTest”.

Steps I have tried to fix the problem:

Running this command…

composer install --no-dev --optimize-autoloader

… seems to resolve the fatal php error, but it also removes a bunch of testing packages that I am not sure will cause issues elsewhere.

Any help would be greatly appreciated.

I haven’t figured out the No sending domain specified issue yet, but I did log a bug for the value encoding issue for the custom header values…

JSON value custom email header values are being html encoded on save

Commenting out the mailer_custom_headers line below in the file app/bundles/EmailBundle/Form/Type/ConfigType.php is a quick interim fix…

$builder->addEventSubscriber(
            new CleanFormSubscriber(
                [
                    'mailer_from_email'      => 'email',
                    'mailer_return_path'     => 'email',
                    'default_signature_text' => 'html',
                    'unsubscribe_text'       => 'html',
                    'unsubscribe_message'    => 'html',
                    'resubscribe_message'    => 'html',
                    'webview_text'           => 'html',
                    // Encode special chars to keep congruent with Email entity custom headers
                    //'mailer_custom_headers'  => 'clean',
                ]
            )
        );

So this ended up being caused by the use of an “@” symbol in the “Email sender display name” field, which looks to be a problem in Mautic 5 and wasn’t an issue in 4 (presumably is was being escaped properly in 4).