Tutorial 4 - Email Settings in OpenCart

Tutorial 4 - Email Settings in OpenCart

OpenCart Email setup can be tricky on some hosting server configurations. In this tutorial, we will share about setting up email in OpenCart and troubleshoot some errors that occur when setting up email. Either using email protocol or SMTP, SSL or non SSL.

In the Opencart online shop system, the email function plays a role in sending notifications to customers about orders, new customer accounts, contacts, etc. The first time you have to do after installing Opencart is that you have to set up your email system so that sending email can run normally. If you don't set up your e-mail system properly, you can be sure that notification e-mails and orders will not be sent.

Common problems encountered when email settings are incorrect are:
  • No email is sent during registration, checkout, order status updates, etc.
  • Errors on pages requiring email delivery, such as the register page and checkout page.

Intro - OpenCart Email Settings

During our career at OpenCart, email setup was usually a bit complicated due to the hosting server configuration. Some hosting servers do not allow the use of the mail () protocol in e-mail services.

By default email settings in OpenCart use PHP mail (). Where the mail () function will use a local web server on the hosting server. As follows:

Default email settings on OpenCart

In general you can use this setting. There are only a few obstacles:
  1. If the hosting server disables the mail () function in PHP, the email will practically not be sent.
  2. If the hosting server allows the use of mail (), it will usually send out fine. It is only possible for spam to arrive on some of the destination email servers.
Then, how to solve it?

Email setup with SMTP in OpenCart

This is an alternative solution. Use SMTP as the email delivery protocol. Follow these steps to set up this email protocol in OpenCart.

1. Create a Personal Email Address

The first thing you have to prepare is a Private Email Address which you can create through CPanel Hosting. Personal Email Address is an email with its own domain name. Suppose you want an email that customers will receive is support@hpwebdesign.io. You must create an email name and account to access webmail. Enter the email name and account that you created.
Here's how to create a personal email address.

create a private email address domain via CPanel

After that, look at the SMTP configuration on the server. How:

SMTP settings on the server

Your hosting server may have different settings. Especially on our servers that use Niagahoster services:


SMTP server settings

Watch the outgoing server. There is an SMTP host name and port information.

2. Mail tab

Access System → Settings. Edit store.


Then access the Mail Tab.

3. OpenCart SMTP Mail Settings

Time to setup SMTP mail: Mail Engine, select SMTP
  • Mail Parameters, use: -f {email_address}. Example: -fsupport@hpwebdesign.io or leave the default value blank
  • SMTP Hostname, see the settings in your cpanel. add ssl: // or tls: // if you are using SSL. example ssl: //mail.yourdomain.com. if not using SSL for example: mail.yourdomain.com
  • SMTP Username, fill in the private email address that you created above. For example: info@yourdomain.com, if you want to use sending email from that email
  • SMTP Password, the private email address password that you created above.
  • SMTP Port, the port according to your hosting settings. For SMTP with SSL 465 and for non-SSL 587 SMTP
  • SMTP Timeout, leave the default 5.
  • Additional Alert Email: fill in another email address for cc email notifications, for example your gmail email or something else. If you use more than one email, separate them with a comma (,) for example: abcd @ gmail.com, abcd @ yahoo.com
An example is as follows

Setting SMTP with SSL on OpenCart


Setting SMTP with non SSL on OpenCart

4. Test your Email settings

Test your email configuration by registering via the register page. You can also immediately test ordering goods. If you get an email, your setup was successful.

That's the OpenCart tutorial this time on how to set up email in OpenCart.

May be useful.

Please leave a comment if you have questions related to the discussion above.