Large store owners use SMTP mail function to improve mail delivery rate and avoid spam problems.
This function works well in most sites, but sometimes, it conflicts with the server configuration and results in an error.
“Error: RCPT TO not accepted from server! in system/library/mail.php” is one such reported problem by Opencart store owners when sending message from contact forms or feedback forms.
As a part of our Support Engineers for webhosts, we routinely solve such errors faced by website owners.
Today, let’s discuss the top 2 causes for this error and how we fix it.
“error: rcpt to not accepted from server!” – Reasons and Fixes
Let’s see the top 2 reasons for this error.
1) Incorrect SMTP settings in Opencart
Store owners use SMTP feature to send emails, much like an email client. We have seen cases where incorrect settings like SMTP hostname, username, protocol or port can hinder the server from connecting to the SMTP server.
How to fix?
We verify the following SMTP settings in Opencart panel and confirm the connectivity to SMTP host using the telnet command.
Mail Protocol : SMTP SMTP Hostname : Address of SMTP host. Include the protocol also(ssl://smtp.gmail.com). SMTP Username : Email address of SMTP host. SMTP Password : Email account password. SMTP Port : The port number provided by SMTP host. SMTP Timeout : Timeout provided by SMTP host.
If we notice any issues, we quickly correct the SMTP settings.
2. Security restriction in servers
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 Opencart algorithm, when client puts his contact email address(so that store owner can reply to him via this email) say test@gmail.com, Opencart 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 to fix?
The right solution we suggest is to modify the Opencart contact form module.
It’s a quick fix as we need to edit a few lines. As a precaution, we always take a backup of the files before editing them.
1. Open the file catalog/controller/information/contact.php
2. Change the FROM field in the contact form to be same as store’s email address by modifying the line as below.
$mail->setFrom($this->config->get('config_email'));
3. Change the Sender address as store’s email address by modifying the line as below.
$mail->setSender($this->config->get('config_email'));
4. Set the client’s email given in the contact form as Reply-to email by modifying the below line.
$mail->setReplyTo($this->request->post['email']);
Conclusion
“Error: RCPT TO not accepted from server!” can occur due to incorrect SMTP settings in Opencart or security restrictions in the server. Today, we’ve seen how our Support Engineers fix this issue.
Wow!! Thank you very much. Saved my day!