Logicify / mautic-advanced-templates-bundle

Plugin extends default email template capabilities with TWIG block so you can use advanced scripting techniques like conditions, loops etc
https://logicify.com/?utm_source=github&utm_campaign=mautic-templates&utm_medium=opensource
MIT License
86 stars 57 forks source link

Plugin broke emojis in emails #32

Open jenya opened 1 year ago

jenya commented 1 year ago

When plugin is enabled emojis doesn't work correctly in all emails - no matter is there {% TWIG_BLOCK %} in it or no. Emojis are visible in email builder and preview 🍀 but in sent emails it shows as :four_leaf_clover: Removing plugin fix this. Mautic v4.4.6

MarketSmart commented 1 year ago

This seems like a simple fix, Ill have a look at this. Thank you for providing this information.

imlolman commented 1 year ago

@jenya

To temporarily fix the issue, you can comment out the lines of code causing the problem. The lines in question can be found at the following link: https://github.com/Logicify/mautic-advanced-templates-bundle/blob/675c2577b462dd5f25646c0bc2cb13c500299802/EventListener/EmailSubscriber.php#LL119C1-L120C38

Simply add two forward slashes in front of each line, like so:

// $subject = $this->templateProcessor->processTemplate($props['subject'],  $lead);
// $event->setSubject($subject);

This will temporarily disable those lines of code and allow the program to work as intended. Keep in mind that this is just a temporary fix and after that twig template won't be applied to the subject.

robertvy commented 1 year ago

we are facing the same issue. The "©" symbol in the email body is not displaying correctly and instead appears as ":copyright:". Surprisingly, this issue is only prevalent when emails are sent through a campaign, while it functions properly when sent directly to a contact.

IonutOjicaDE commented 11 months ago

I have found the solution:

Inside the file: /EventListener/EmailSubscriber.php

add on line 14:

use Psr\Log\LoggerInterface;
use Monolog\Logger;
use Mautic\CoreBundle\Helper\EmojiHelper; /* enable Emoji - add needed reference */

/**
 * Class EmailSubscriber.
 */
class EmailSubscriber implements EventSubscriberInterface

and on line 121 and 126:

        $subject = $this->templateProcessor->processTemplate($props['subject'],  $lead);
        $subject = EmojiHelper::toEmoji($subject, 'short'); /* enable Emoji in Subject - add this line */
        $event->setSubject($subject);

        $content = $this->templateProcessor->processTemplate($props['content'],  $lead, $props['tokens']);
        $content = $this->templateProcessor->addTrackingPixel($content);
        $content = EmojiHelper::toEmoji($content, 'short'); /* enable Emoji in Content- add this line */
        $event->setContent($content);

I do not know how to add a PR for this change... if someone would be so kind to add the PR to implement the changes :)

corvis commented 11 months ago

@MarketSmart can you take a look please?