{unsubscribe_url} results in error 500

Your software
My Mautic version is: 5.1.1
My PHP version is: 8.1.26
My Database type and version is: 10.11.9-MariaDB-0+deb12u1

Your problem
My problem is:

The Unsubscribe Link does not work. I can’t say since when, but it must be since an update. I don’t check this every time, I’m composing an email.

These errors are showing in the log:

mautic.CRITICAL: Uncaught PHP Exception Twig\Error\LoaderError: “Unable to find template “:divine-partnership:base.html.twig” (looked into: /var/www/clients/client1/web49/web/mautic/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views, /var/www/clients/client1/web49/web/mautic/vendor/symfony/twig-bridge/Resources/views/Form) in “@themes/divine-partnership/html/message.html.twig” at line 1.” at /var/www/clients/client1/web49/web/mautic/vendor/twig/twig/src/Loader/FilesystemLoader.php line 234 {“exception”:“[object] (Twig\Error\LoaderError(code: 0): Unable to find template ":divine-partnership:base.html.twig" (looked into: /var/www/clients/client1/web49/web/mautic/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views, /var/www/clients/client1/web49/web/mautic/vendor/symfony/twig-bridge/Resources/views/Form) in "@themes/divine-partnership/html/message.html.twig" at line 1. at /var/www/clients/client1/web49/web/mautic/vendor/twig/twig/src/Loader/FilesystemLoader.php:234)”} {“hostname”:“mars”,“pid”:112569}

The problem with this is, that the lookup path is wrong. Templates are not located under knblabs/knp-menu/src/Knp

How comes that Mautic looks there for the template.

Steps I have tried to fix the problem:
Deactivate Twig Plugin.

No success.

There is a message with this topic, but no solution.

Many thanks

Christian

The strange thing is, that if the unsubscribe link i.e. {unsubscribe_url} is clicked from a “Truly Personal” email template, the link works properly.

If the same link is placed in a custom email template again via {unsubscribe_url} and clicked then, the error occurs.

I copied the two links and compared them. They are identical.

I deleted the cache, did an update via composer, checked the rights.

Does your custom template have all the necessary twig files (base.html.twig and message.html.twig for example)?

Yes, all of them:

base.html.twig
email.html.twig
email.mjml.twig
message.html.twig

I have to revise my former post. The links are not identical. They differ in the number after the unsubscribe:

https://website.com/email/unsubscribe/67500de418ce4807651794/mail@gmail.com/69a087ed11dde3f256b34dd893807630cbc9fe650f477169e05e6c3b5257df54
https://website.com/email/unsubscribe/67500ddaa0488012951510/mail@gmail.com/69a087ed11dde3f256b34dd893807630cbc9fe650f477169e05e6c3b5257df54

I guess that number is a kind of template ID where the link is placed.

Hello @taxi,

The unsubscribe functionality is working correctly, and the issue you’re facing is not related to the update. I am 99.9% certain that the problem lies with your custom email theme.

Here’s what you can do:

  1. Visit my website and download any template you like. (This article might be helpful.)
  2. Edit only the email.mjml.twig file. Delete the entire email template and paste your own. Don’t forget to validate your email code here.
  3. After validation, copy the validated email code and paste it into the email.html.twig file.
  4. (Optional) If you’d like, you can modify the thumbnail, composer.json, and config.json. These can also be updated later, once you’re sure your email is working fine.
  5. Save the template and upload it to your Mautic instance.

Once you’ve done this, check if the error appears again. If you need further assistance, feel free to reach out to me on Mautic’s Slack :smile:

Best regards,
Ricardo

Many thanks Ricardo,

so kind.
I fixed it in the way, that I took another default email template and modified it via the template editor and the unsubscribe link works now.
It was for me the faster way, than checking what the problem with my custom footer was.

Beste regards

Christian

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.