In one of our previous articles we reviewed the process of creating a model in Prestashop MVC. In this article we are going to elaborate the topic and will describe the steps to create a controller in Prestashop.
Recently we faced the problem, that customers did not receive email notifications from the client’s Prestashop installation.
For a long time we couldn’t reproduce this issue: MTA settings were correct, Mandrill API did not return any errors. Issue exited only for a couple customers, while hundreds did not get such error at all.
Luckily we new the email address of one of clients who complained about the issue, so we created additional development instance and replaced customer’s email with ours. So now we could repeat all process like a real customer with his unique data. We tried to send an email for this user (the email was supposed to go to our email address). And we didn’t receive any. This current Prestashop installation uses Mandrill as the SMTP server, but there was no any information about customer’s emails in the “Outbound” section. Though debug log showed that the API call to the Mandrill was sent and did not return any error.
To cut a long story short, after some time we finally spotted the problem. The thing was that customer used Danish special characters (such as Æ,Ø, Å) in his username. Also we found the following post on the forum.
The solution was to encode “To name” field with the base64 encoding. After this fix all letters were delivered to the client.
Our solution was to make override for the class of the function Mail::Send
public static function Send($id_lang, $template, $subject, $template_vars, $to,
$to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
$template_path = PS_MAIL_DIR, $die = false, $id_shop = null, $bcc = null)
$to_name = base64_decode($to_name); //string encoding