Prestashop email not working – Causes and Fix
Prestashop owners can use either SMTP or PHP mail() function to send contact form emails, order confirmation emails and so forth.
Due to ease of use, some store owners prefer mail() over SMTP. Sometimes, this can conflict with server security settings and may result in errors.
“My Prestashop email does not work” is a common problem raised by store owners.
At Bobcares, we often resolve such email errors as part of our Technical Support Service for web hosting companies.
One such error is :
"Sending failed using mail() as PHP's default mail() function returned boolean FALSE"
Today, let’s see the top 2 reasons for this error and how we fix it.
Why Prestashop emails do not work, How to fix it?
Prestashop email errors can occur mainly due to the security restrictions in the server.
1. Disabled PHP mail() function
PHP mail() is an inherently vulnerable function. Hackers can exploit it and send spam.
To prevent this, some hosts may disable this mail() feature.
How we fix?
Our Hosting Engineers confirm whether the mail() function is disabled or not using a phpinfo page(<? phpinfo(); ?) in the website.
If this function is disabled, it will display under disable_functions list.
We then suggest the option to use SMTP function to send emails.
You can use the following SMTP settings in your Prestashop email configuration.
Mail domain name : Your store name. SMTP server : Your SMTP server. SMTP user : Your complete email account. SMTP password : Your email account password. Encryption : Either SSL or TLS encryption. Port : SMTP server port.
2. Security restrictions in the server
We see email providers use a security feature called SPF(Sender Policy Framework) to check the email authenticity of the sender.
It decides the servers that can send emails on behalf of a domain.
When emails don’t originate from the servers mentioned in the SPF record of the domain, mail server assumes it as fraud and rejects them.
As per Prestashop algorithm, when client puts his contact email address, say email@example.com, the system automatically assigns this email address as the FROM address of the message.
Consequently, the receiver end sees an email claiming to be FROM gmail.com, which is actually from a completely different server. Hence, it fails the SPF check process and mail bounces with the above error.
How we fix?
The quick solution is to modify the Prestashop Swift Mailer module.
We need to modify 3 files here. But before that, we always take a backup of the files.
1) Open the file /tools/swift/Swift/Message.php and change the FROM field to be an email associated with your domain.
2) Open /tools/swift/Swift.php and add client’s email given in the contact form as Reply-to email by modifying the below line.
if (!($has_reply_to = $message->getReplyTo())) $message->setReplyTo($from);
if (!($has_reply_to = $message->getReplyTo())) $message->setReplyTo($from); if (!$has_reply_to) $message->setReplyTo($from->getAddress());
3) Open /tools/swift/Swift/Plugin/MailSend.php to disable additional parameters in the message.
$headers = $headers->build();
$headers = $headers->build(); $params = "";
That’s it. Your Prestashop site should now be able to send emails.
Prestashop email errors can occur due to security restrictions in the server. “Sending failed using mail() as PHP’s default mail() function returned boolean FALSE” is one such error. Today, we’ve discussed the top 2 reasons for this error and how our Hosting Support Engineers fix them.