Can't load New Template Email

Your software
My Mautic version is: 3.3.2
My PHP version is: 7.4.16
My Database type and version is: 10.2.37-MariaDB
My OS: Centos 7

Your problem
My problem is: When I’m trying to load new template email I get blank page.

These errors are showing in the log:
[2021-04-06 18:32:53] mautic.CRITICAL: Uncaught PHP Exception RuntimeException: “Unable to write in the cache directory (/var/www/html/app/…/var/tmp/twig/2d).” at /var/www/html/vendor/twig/twig/src/Cache/FilesystemCache.php line 61 {“exception”:"[object] (RuntimeException(code: 0): Unable to write in the cache directory (/var/www/html/app/…/var/tmp/twig/2d). at /var/www/html/vendor/twig/twig/src/Cache/FilesystemCache.php:61)"}

Steps I have tried to fix the problem:
I tried to restore/setup file permission but nothing changed.

sudo chown -R apache:apache /var/www/html/var/tmp/
chcon -t httpd_sys_content_rw_t /var/www/matomo/tmp

Thank you!

I tried to set all the permissions to apache user but I still get this:

[2021-04-07 12:09:08] mautic.CRITICAL: Uncaught PHP Exception RuntimeException: “Unable to write in the cache directory (/var/www/html/app/…/var/tmp/twig/02).” at /var/www/html/vendor/twig/twig/src/Cache/FilesystemCache.php line 61 {“exception”:"[object] (RuntimeException(code: 0): Unable to write in the cache directory (/var/www/html/app/…/var/tmp/twig/02). at /var/www/html/vendor/twig/twig/src/Cache/FilesystemCache.php:61)"}

Can someone help?
Thank you!

Here is the solution: CentOS 7 + SELinux + PHP + Apache – cannot write/access file no matter what | Lysender's Daily Log Book

sudo chcon -t httpd_sys_rw_content_t /var/www/html/var/tmp/ -R worked for me! :slight_smile:

1 Like

If you are using a Docker environment this also can be caused by a bad (i.e. not writable) location defined in app/config/local.php under the tmp_path key.

On my side, in a Docker env, the Docker volume was mounted to the /var/www/html/ inside the container, which means all the Mautic content was at that location.

The problem is that my key was:

        'tmp_path' => '/var/www/tmp/',

which wasn’t a writable location inside the container, changing it to:

        'tmp_path' => '/var/www/html/var/tmp',

fixed the issue as it was pointing to a location inside the mapped Docker volume.

Your champion, and your solution worked for me to fix my Unsubscribe page not working in my Mautic Docker Container. I noticed a couple of things (and I used EasyPanel to build Mautic v4.4.9 on Ubuntu 22.04 LTS Docker Build) - So I went to the terminal and I entered the config file and found that it said

‘tmp_path’ => ‘/var/www/html/app/…/var/tmp’,

so I changed this to how you reccommended it which, just to clarify for others was

‘tmp_path’ => ‘/var/www/html/var/tmp’,

A quick question for you though @wget do I also need to be concerned about path to cache directory and path to log directory as picture below? I noticed that I changed ‘tmp_path’ => ‘/var/www/html/app/…/var/tmp’, to what you suggested to ‘tmp_path’ => ‘/var/www/html/var/tmp’, and that those have very similar file structure…

For those that want an easy tutorial on how to fix this please see below…

This is how it now looks in my terminal right near the top of the file

PS - to get to this file you are going to have to be in root - it would not allow me even with a non root user that had sudo priviliges, just ask ai and it will help you get to your file but my structure looked like this (in EasyPanel anyways)

root@srv557064:/etc/easypanel/projects/clientsprojectname/mautic/volumes/mautic_data/app/config# nano local.php

So after this, my unsubscribe page finally worked, I am guessing that is because of what you are talking about in regards to the tmp_path key and those users having a temporary access key or something to see their custom landing page for unsubscribe… for anyone else that wants a nice unsubscribe email template, here is the code for it below that works with the {unsubscribe_text} at the bottom of your emails, you need to put this in Configuration → Email Settings → Unsubscribed confirmation message Section

here is the code for that if you want to put in Configuration>Email Settings>Unsubscribed confirmation message

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Unsubscribed</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .container {
            background-color: white;
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            text-align: center;
            max-width: 400px;
        }
        h1 {
            color: #4a4a4a;
            margin-bottom: 20px;
        }
        p {
            color: #666;
            line-height: 1.6;
        }
        .emoji {
            font-size: 48px;
            margin-bottom: 20px;
        }
        .button {
            display: inline-block;
            padding: 10px 20px;
            background-color: #3498db;
            color: white;
            text-decoration: none;
            border-radius: 5px;
            transition: background-color 0.3s ease;
        }
        .button:hover {
            background-color: #2980b9;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="emoji">👋</div>
        <p>We are sorry to see you go! |EMAIL| will no longer receive emails from us.</p>
        <p>If this was by mistake, <a href="|URL|" class="button">click here to re-subscribe</a>.</p>
        <p>If you ever change your mind, feel free to email us back!</p>
    </div>
</body>
</html>