Fixing Broken Email Template Images When Running Mautic in a Folder

mautic missing email images

I first ran into this issue after installing a local copy of Mautic to develop some custom Email templates.

Everything looks fine until you open up the email builder and images added in the Email Twig template don't show.

The fix is pretty simple if a little counter intuitive.

WARNING: It seems like this can break email tracking links. Do not do this on a production website or links in Emails may all go to 404 error pages!

When you install Mautic, the site url will automatically be saved in the general configuration (app/config/local.php). The url will be saved including the name of the folder that Mautic was installed into.

Mautic General Configuration

The problem here is that the default .htaccess file that comes with Mautic will auto-detect the folder that it is installed into and use that as the 'RewriteBase'.

# Determine the RewriteBase automatically and set it as environment variable.
# If you are using Apache aliases to do mass virtual hosting or installed the
# project in a subdirectory, the base path will be prepended to allow proper
# resolution of the app.php file and to redirect to the correct URI. It will
# work in environments without path prefix as well, providing a safe, one-size
# fits all solution. But as you do not need it in this case, you can comment
# the following 2 lines to eliminate the overhead.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]

Because the rewriteBase is set to the installation folder, the folder appended to the site URL setting in the general configuration causes the folder name to be added twice to the image src attribute.

So the fix is to remove the folder from the site URL in the general settings.

In this case, I change the setting from:




and the images then show up in the email builder.