As we see some Opencart users are complaining that their email is not working in Opencart and not able to see the contact us form message or the order message or other updates. We have listed some of the ways to fix them.
Email code in Opencart
Whenever Mail class is instantiated like below and called send method then you can say Opencart is sending an email. Example email code is:
mail = new Mail($this->config->get('config_mail_engine')); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); $mail->smtp_username = $this->config->get('config_mail_smtp_username'); $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); $mail->smtp_port = $this->config->get('config_mail_smtp_port'); $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); $mail->setTo($customer_info['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($store_name); $mail->setSubject($subject); $mail->setText($this->load->view('mail/customer_approve', $data)); $mail->send();
You can find these codes in admin/controller/mail/forgotten.php, catalog/controller/mail/register.php, catalog/controller/mail/order.php, catalog/controller/mail/affiliate.php, etc.
Check the email settings again
Login to admin of Opencart >> System >> Settings >> Edit the store that email is not sending >> click the Store tab >> Check if the email is set or not.
This email is the reply-to email.
Now, click the Mail tab, here are the settings to enter the email details.
Mail Engine: You can choose either Mail or SMTP in the Mail engine. Only choose ‘Mail’ unless your host has disabled the PHP mail function.
Mail: When you choose the Mail option, enter your email in the Mail Parameters. It is always best to enter the email of your website rather than using Gmail email or other email clients. If you send emails from other emails than your website then receivers can take it as spam. Like in the example: we use firstname.lastname@example.org. If you choose Mail then you don’t need to enter the SMTP details.
Sometimes, you need to enter the Mail Parameters as -f email@example.com
You can use third-party email services which provide SMTP to send an email. All SMTP provides the following information
- SMTP Hostname
- SMTP Username
- SMTP Password
- SMTP Port
Here is one example, one of the SMTP providers provides the following information:
Enter the above SMTP settings in the Opencart by choosing the Mail engine as SMTP
Every SMTP provider gives you the above information. The only thing is it can cost you extra.
Check Mail Alerts settings
Go to admin >> System >> Settings >> Edit store >> Mail tab >> Mail Alerts section
If you did not check the checkboxes for the one that you want to be alerted then these need to be checked.
Check all Events are set properly for Opencart 3
From Opencart 3.0+ all mail needs to be set as Events in Opencart. Go to admin >> Extensions >> Events and check if all of the below events are added or not.
With the above setting, an email should be sent if all servers’ settings are good.
Server checking for email issues
Check for MX records:
Check if MX records are added for your domain or not. You can look for an online tool that checks for MX records. Here is one example:
If you did not have the MX records then you need to add them.
Once your MX records are added, now is time to check for Email Routing
If you are sending email from your server and you have chosen Mail as “Mail Engine” then check for Email Routing in the server and see whether the Email routing is configured to Local Mail Exchanger. But if you are using SMTP then the Email routing needs to be configured to Remote Mail Exchanger.
Check your email quota of your server
Most of the email servers have some email quota so if you reach that number they blocked sending the email, so verifying with the hosting provider is a way to check as well.
Sometimes you get an email like the below from your hosting provider.
This message was created automatically by mail delivery software. A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed: Domain ****.com has an outgoing mail suspension. Message discarded.
Check if your hosting provider blocked the email services
Sometimes hosting providers or servers block the email services and they even block the third party services or SMTP, they need to unblock the mail services, so ask them to unblock it.
See one example they have posted on their website:
Upon checking the logs, I see that the email services were suspended for sending more than 1000 messages in the past 24h on November 19th, 2020 which was 2 years ago. We do have an email sending limit on our shared/reseller hosting which is 500 emails per hour, and 1000 emails per day for an account in which exceeding the limit causes email services to suspend.
Check your mail filter settings
If you don’t receive mail from a particular email you can whitelist it in your mail filter and check the spam folder as well.
In this Opencart user manual, we went through email not sending issues, and ways to solve them. Please don’t forget to post your questions or comments so that we can add extra topics. You can follow us at our Twitter account @rupaknpl, and subscribe to our YouTube channel for an opencart tutorial. Click to see all Opencart user manuals.