If your store name has a special character in it, such as an apostrophe, it will be converted to a numerical character reference in any email subject. For example:
Store name: Bob's Burgers
Reset password email subject: Reset your Bob's Burgers password
I've tried sending the email directly with php and with Zend_Mail without issues, so it must be somewhere in Magento's email template handling.
@mattcoz thank you for your feedback.
Please, format this issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result.
Please, also identify which version of Magento you are running.
Steps to reproduce:
Expected result:
Subject should be "Reset your Bob's Burgers password"
Actual result:
Subject is "Reset your Bob's Burgers password"
@mattcoz thank you for update.
I have created internal ticket for this issue: MAGETWO-63154
@veloraven Is there a way to track this ticket ?
Im not sure if you want me to raise another issue, but this happens all the way through the emails.
So If a customer submits via contact form the same thing happens - apostrophe is converted like the example above.
I can confirm that this issue appears in other email as well. For example, when you share a wishlist via email, the subject according to this line and then in your inbox it is also shown with this weird '
inside.
In particular case of the wishlist, the issues seems to be coming out of this little quirk which doesn't seem to care whether the directive is invoked inside subject or body of the email.
To anyone struggling, this is quite an easy workaround: in a given template just add that |raw
part at the end of the directive, like in the following:
<!--@subject {{trans "Take a look at %customer_name's Wish List" customer_name=$customerName|raw}} @-->
Probably related #6597 and MAGETWO-58663 which is referenced in that issue.
@korostii Thanks for the workaround, unfortunately it's a pain to have to override every single email template file to fix this. Instead I created a simple plugin to reverse the encoding.
public function afterGetSubject(\Magento\Email\Model\Template $subject, $result)
{
return htmlspecialchars_decode((string)$result, ENT_QUOTES);
}
Quick fix is in di.xml
```
In Template.php
```<?php
namespace VENDOR\MODULE\Plugin;
class Template
{
public function afterGetSubject(
\Magento\Email\Model\Template $subject,
$result
) {
return htmlspecialchars_decode((string)$result, ENT_QUOTES);
}
}
This issue was fixed in develop branch.
Closed.
Hi @veloraven, having a fix on develop isn't the same as resolving the issue.
Are there any plans to backport this issue on Magento side?
If not, please reopen the issue and mark it as "up for grabs" so that people would know it is okay to create a pull request targeting 2.1-develop
in order to help with the backporting process.
return htmlspecialchars_decode((string)$result, ENT_QUOTES);
This didn't work for me but this did:
return mb_encode_mimeheader((string)$result,"UTF-8");
In what develop branch is this fixed then? Because it still persists in 2.1.8.
@magento-engcom-team The issue is still present, please reopen (see the comment above).
@korostii this issue was fixed in 2.2.0. You can find related commits there:
https://github.com/magento/magento2/search?q=MAGETWO-63154&type=Commits&utf8=%E2%9C%93
@magento-engcom-team looks like it wasn't fixed in 2.1.x
This issue is still in in 2.2.4
Also the System does not retrieve the subject line when opening the email template.
Hi @kemexyz ,
It looks very similar, but it's different. Could you report it as separate issue?
Hey @ihor-sviziev ,
sure, not quite sure if got 2 issues mixed up here ... sorry!
Quick fix is in
di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Email\Model\Template"> <plugin name="mail_subject" type="VENDOR\MODULE\Plugin\Template" sortOrder="100" /> </type> </config>
In Template.php
namespace VENDOR\MODULE\Plugin; class Template { public function afterGetSubject( \Magento\Email\Model\Template $subject, $result ) { return htmlspecialchars_decode((string)$result, ENT_QUOTES); } }
Quick fix is in
di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Email\Model\Template"> <plugin name="mail_subject" type="VENDOR\MODULE\Plugin\Template" sortOrder="100" /> </type> </config>
In Template.php
namespace VENDOR\MODULE\Plugin; class Template { public function afterGetSubject( \Magento\Email\Model\Template $subject, $result ) { return htmlspecialchars_decode((string)$result, ENT_QUOTES); } }
Where i can put the code can you help i am new in magento
Most helpful comment
Steps to reproduce:
Expected result:
Subject should be "Reset your Bob's Burgers password"
Actual result:
Subject is "Reset your Bob's Burgers password"