Written on 7. December 2017 by Lennart Christensen

WordPress email problems - SMTP setup

For a customer interaction website to run 100%, it must be able to communicate clearly to users and potential customers. Therefore, e-mail contact from your website is one of the most important tools we have available, especially for webshops that base a lot of e-mail contact on being able to send invoices, order confirmations, etc. Often, however, something goes wrong with the transmission, and we take a closer look at that.

It often happens that a brand new WordPress website has been set up and is running from there. However, there is just one problem. Any emails sent through forms on the site, order emails from WooCommerce, or just security emails from the control panel get lost. The forms report no errors, various logging plugins report no errors, and everything seems to be working. So what is going wrong?

WordPress uses PHPMailer

By default, WordPress uses a feature to send emails, known as PHPMailer. The problem with this feature is that at the basic level it is often completely sorted out by the major email clients. Therefore, the email will either end up in the spam folder of the recipient, or be completely sorted out so that it doesn't end up with the intended recipient. At the same time, your website will report that everything is fine on the email front, as nothing has gone wrong technically in its systems. So the problem only occurs after the email has left your site, and is sorted out by the recipient's email provider.

So what's the problem with WordPress?

The problem is caused by spam emails. About 80% of all emails sent on the Internet are categorized as spam. In order to avoid sending all these emails themselves, spam senders typically use features that make it easy, fast and automatic for them. One of these methods is through systems like PHPMailer. This means that a lot of e-mails are grey-listed from the moment they are sent, unless they are set up through a so-called e-mail server running SMTP. SMTP, or Simple Mail Transfer Protocol, handles your emails from start to finish, and it's typically also an SMTP client that receives the emails you send, or rejects them if it can't recognise the SMTP sender. Another difference between SMTP and more traditional email systems is that more traditional email systems like PHPMailer send an email, and do nothing more after that. SMTP waits for the connection to the recipient to be opened, and if it doesn't work the first time, it tries again. The retry alone reduces spam by over 80%.

How do we solve the email problem in WordPress?

To solve the problem, we need to set up our WordPress site to run over SMTP. This typically takes several steps, as there are several factors involved.

First of all, it requires that you have the SMTP information for the email you are trying to send from. If your email is offered by your website host, you can typically query them for the necessary SMTP information. If your email is offered by a dedicated mail provider (Windows/Hotmail/Live mail/Outlook, Google mail, Yahoo mail, etc), you should contact their support to get the relevant information.

Typically, the following information is required:

  • SMTP host - This is the server we want to send through
  • SMTP port - This is a communication port that the server wants us to communicate with it through

In the majority of cases, you will also need:

  • Username
  • Password
  • Security encryption - Typical choices are "None", "TLS", and "SSL". Ask your email provider which one they use

With this information, you are now ready to set up your WordPress installation to run over SMTP. If you like to use plugins for this purpose, we recommend WP Mail SMTP for the purpose. This also allows you to send a test email to confirm that your website is now sending the email correctly.

The system is easy to set up, provided you have the information mentioned above.

First, select the sender email and name that you want to appear on the email you send. Typically, the sender email should be the same as the one you use for username when authenticating your SMTP user, as some SMTP servers may reject you if they do not match. Next, select the email service you want to send through.

PHP is the default, and runs over the aforementioned PHPMailer system, but often you need to select "Other (SMTP)" unless your email service runs over one of the other clients shown.
Finally, enter the information provided by your email provider and then save. If this works, you should now be able to send an email through the "Email test" tab without any problems.

If you'd rather do it yourself, Github user "butlerblog" has made this simple guide for how to make it work with your functions file and wp-config respectively. This requires some prior knowledge of both files, however.

Yield and result with WordPress SMTP setup

So what do we get out of setting all this up? Simply put, we can now expect our emails to arrive as they should, and that we can count on the emails sent from the site actually getting where they need to go at all times. It may be a major task for some to go through this setup, but the result is undeniable, and is one of the most important steps you can take to ensure your WordPress site gets emails delivered correctly to recipients. Remember to also set up an SPF record and preferably a DKIM key.