OpenCart – SMTP vs PHP MAIL

Okay so here we go! This is a very hot topic on the Opencart forums so I wanted to write my own ideas on the matter to try and separate fact from fiction and hopefully point/guide you in the right direction. Email is clearly a very important aspect of any business whether it be online or offline but especially if the majority of your business comes from online sales. First, let’s look at what SMTP and MAIL are.

What is SMTP?

What is PHP MAIL?

PHP Mail() is a library devoted to sending web mail and has established itself as “the” industry standard.

What are the differences between the two?

Whether you host your own separate server or use a third-party service, Simple Mail Transfer Protocol (SMTP) is the easiest method to have your web server interact with an email server. Most of the third-party services have their own unique APIs, but they typically support SMTP. I would recommend using SMTP at least until you find a service that you love. After that, you might want to integrate with them more tightly through an API to take advantage of some more advanced features — or you may want to keep using SMTP to make it easier to switch to a different service in the future.

To use SMTP in your PHP code, I recommend using PHPMailer. This third-party library provides the settings and functions you need to send email using a variety of methods, including SMTP. You can find an SMTP example in the test_smtp_basic.php file in the examples folder of the library.

PHP MAIL is also a part of the library phpMailer and is used more commonly than SMTP. It perhaps can take a little longer “at times” for mail to reach your destination due to relay but it is a lot easier to set up and normally comes with fewer errors. Most people that sign up with Opencart choose php mail() instead of SMTP but as people grow their business they find need of a larger server perhaps even their very OWN MAIL server in which case you would NOT be using php Mail() any longer.

When it comes down to it you should just use what is best for you and is suitable for the web host that you are involved with.