3

I am sending a custom email, the custom template data is in Spanish. if the template is in the English language it's working perfectly. but in Spanish language, it shows me unknown error. it's not working if characters are like: ú, ó

Its not working with below code:

{{trans "%body" body="Transacción"|raw}}

Error:

Unable to send mail: Unknown error

2
  • Is strange, we use the same format for an accented string: {{trans "Política de Privacidad"|raw}} Is your store locale set to spanish?
    – SantiBM
    Jul 24, 2019 at 12:38
  • @SantiBM Yes my store is in Spanish, other Magento email is working with spanish language. Jul 24, 2019 at 14:42

1 Answer 1

0

We can use HTML Codes for Spanish Language Characters ú to make it take ú in email template,

Make sure the type is html type="html" in YourVendor/YourModule/etc/email_templates.xml

Here are the different Spanish characters you may want to use:

Display FriendlyCode    NumericalCode   Hex Codes       Description

Á       Á        Á          Á          Capital A-acute
á       á        á          á          Lowercase a-acute
É       É        É          É          Capital E-acute
é       é        é          é          Lowercase e-acute
Í       Í        Í          Í          Capital I-acute
í       í        í          í          Lowercase i-acute
Ñ       Ñ        Ñ          Ñ          Capital N-tilde
ñ       ñ        ñ          ñ          Lowercase n-tilde
Ó       Ó        Ó          Ó          Capital O-acute
ó       ó        ó          ó          Lowercase o-acute
Ú       Ú        Ú          Ú          Capital U-acute
ú       ú        ú          ú          Lowercase u-acute
Ü       Ü          Ü          Ü          Capital U-umlaut
ü       ü          ü          ü          Lowercase u-umlaut
«       «         «          «          Left angle quotes
»       »         »          »          Right angle quotes
¿       ¿        ¿          ¿          Inverted question mark
¡       ¡         ¡          ¡          Inverted exclamation point
€       €          €          €          Euro
₧                       ₧         ₧        Peseta

If still not working you can create plugin:

Define plugin: YourVendor/YourModule/etc/frontend/di.xml

<?xml version="1.0"?>
<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="YourVendor\YourModule\Plugin\Template" sortOrder="100" />
    </type>
</config>

Create Plugin:

<?php 
namespace YourVendor\YourModule\Plugin;

class Template
{
    public function afterProcessTemplate(
        \Magento\Email\Model\Template $subject,
        $result
    ) {
        return htmlspecialchars_decode($result, ENT_QUOTES);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.