3

I have an issue with transactional emails with special characters (é, è, à, etc.)

For the "Official Emails" such as "order_new.html" which are sent by magento core, everything works fine and all the special characters are well displayed in the mailbox.

But for custom transactional emails I define in Backend and send using custom modules special characters are not displayed correctly

ex : été vérifiés avec succès

I tried defining utf-8 encoding both in email template and in the module code with setHeader(), but I have the same result.

Here is my code :

$mail = Mage::getModel('core/email')
        ->setToName($ToName)
        ->setToEmail($ToEmail)
        ->setHeader('Content-type', 'text/xml; charset=UTF-8')
        ->setBody($processedTemplate)
        ->setSubject('tototototo')
        ->setFromEmail($senderEmail)
        ->setFromName($senderName)
        ->setType('html');   
2
  • Did you fix it ? :) Facing the same issue Feb 20, 2018 at 9:09
  • see below. I use zend mail
    – Alexglvr
    Feb 20, 2018 at 13:47

2 Answers 2

5

I managed to find a solution by using Zend Mail :

$mail = new Zend_Mail('UTF-8');
$mail->setType(Zend_Mime::MULTIPART_RELATED);
$mail->setBodyHtml($processedTemplate);
$mail->setFrom($senderEmail, $senderName);
$mail->addTo($ToEmail, $ToName);
$mail->setSubject('I love UTF8');

If it can help...

1

If you're using Ashroder_SMTPPro module, and you use the @Alexglvr's approach above, you'll always be sending emails using sendmail (instead the configured method on SMTPPro).

If you want to use your configured SMTP Settings in Ashroder's module, you may want to do something like:

$transport = null;
//if Aschroder is enabled, we try to get the transport configured in the admin. Otherwise, it will use default sendmail.
if(Mage::helper('core')->isModuleEnabled('Aschroder_SMTPPro')){
    $helper = Mage::helper('smtppro');
    $transport = $helper->getTransport();
}
//Confimation E-Mail Send
$mail->send($transport);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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