Have your WordPress form emails have been a source of frustration? Worry no more. This 3 step guide will show you how to avoid the biggest email pitfalls!
Help! WordPress is not sending emails!
We already have a troubleshooting guide for WordPress email issues, but we want to go into a little more depth on this subject. Here's a step-by-step guide on how to setup SMTP on your website, and a little insight into the reasons why SMTP has become an essential part of modern WordPress websites.
SMTP vs wp_mail
SMTP stands for "Simple Mail Transfer Protocol". It relies on a connection to an external mailserver to send email messages. This requires some setup and configuration, but has some huge advantages and is definitely worth the effort!
WordPress has email functionality in its core with the wp_mail function. It's simple, requires zero configuration, and worked reliably for years.
Why do we need SMTP?
Email SPAM and how it affects you
Your messages used to send using the built-in WordPress email system. But why is WordPress not sending emails anymore? The simple answer is spam, and our fight against it. Email spam reached epic proportions in 2010. Since then, the largest and most clever internet authorities have been cracking down hard on spam email, introducing systems to identify it and delete it before it hits your inbox.
Email spam is at a 10-year low, falling to 49.7% in June, according to security company Symantec. This was the first time in a decade that spam made up less than half of all emails. Overall, average spam rates annually have been on a downward trend.*
While crackdowns on spam email are good news in general, it is hard for automated spam filters to reliably distinguish genuine messages from spam messages. Unfortunately, messages sent via WordPress mail often trigger spam defenses and instant deletion. Sending messages via SMTP and a known mailserver helps your form-generated messages look more legitimate and reach their destinations intact.
Emails sent through your web host
Under default conditions, your WordPress emails are handled by your web host. Once WordPress or a plugin on your site triggers an email, the control goes to your web host. Some web hosts are definitely more reliable than others, but even the best of hosts will not have 100% reliable email notifications.
Shared hosting is one area where issues can arise. There may be thousands of domains using the same IP address and mailserver - and all it takes is for one unscrupulous user to start spamming - or even one hacked site to go unnoticed, and the reputation of all messages sent via that server can take a hit.
I've also personally seen messages rejected by mailservers on .gov domains which may have tighter security than normal, even when messages sent from the same mailserver were delivered successfully to all other addresses on the list. If you do business with government or security agencies, you may have experienced similar frustrations.
The issue can be compounded further in some cases. Bluehost uses separate servers to send emails from heaps of shared servers. These email servers are limited on the number of emails they can send out per minute. If one of the thousands of sites using Bluehost decide to send out a large mailing, everyone else suffers with email delays.
SMTP completely bypasses your web host, so you are no longer at their mercy. When the WordPress email is triggered, it goes to your email provider rather than your web host. They specialize in reliable email, so your chances of deliverability are far, far higher.
What you need to know about switching
First, it's easier than you think. Once you've found the right settings from your mail provider, the whole process can be completed in 10 minutes flat. It is a completely "set and forget" solution. You won't need to go back and adjust settings on a regular basis.
Second, your users won't know anything has changed. It won't negatively impact the user experience. In fact, if they now get all your messages reliably, it could have a huge positive impact!
Third, you're going to have to do this sooner or later.... So why not do it now?
Getting started - Choose your SMTP plugin
There are hundreds of SMTP plugins to choose from. I've yet to find one that didn't work as expected. However, my personal choice is usually "Postman SMTP" because this plugin logs all messages when they are sent. These logs are handy for troubleshooting issues or re-sending messages at the click of a button when required. This tutorial is based around the Postman SMTP plugin. But the settings are fairly similar in most other plugins too.
Login to your WordPress dashboard, click on the Plugins tab, select "Add New" and search for Postman SMTP. When you find it, click install, and then activate.
Update October 2017: Postman SMTP is no longer available due to unpatched security vulnerabilities.
Step 2 - Find your SMTP settings
Your SMTP settings depend on the email service you use. You will always need your email address (username) and your email password. You also need to know your mailserver name. In most cases the default port numbers work without modification, but take note of the port numbers your service provider specifies just in case there are issues.
A quick Google search will uncover the settings for most major providers.
If your email address is connected to your domain name, eg. email@example.com, then you can usually find your SMTP settings in your hosting control panel.
*Pro Tip* For self hosted email mailboxes, adding "mail." before the domain name usually gives you your mailserver name, eg. mail.mydomain.com, and the default port numbers (25 or 465) usually apply too.
Step 3 - Configure Postman SMTP
Configuring the plugin is easy once you have all your information on hand. Once the plugin is activated, a new item will appear at the bottom of the Settings menu. Click on the 'Postman SMTP' menu to see the current status, a count of how many emails have been delivered, and a link to the email log.
If you are using Gmail, Yahoo, Hotmail or any of the other main email providers, it's often easiest to use the Setup Wizard option, and enter your details on each step. This process is self-explanatory and the system takes you through it step by step. If it won't work for you, follow the instructions below to manually setup your details.
If you use a self-hosted email mailbox, or an SMTP service like SendInBlue to send messages, the "Show All Settings" option allows you to manually enter your information.
- Choose "SMTP" in the dropdown menu, and then enter your mailserver name, port number and from-address details.
- Next, select your Authentication method in the bottom dropdown and enter your email username and password.
- You'll also need to fill out your name, envelope from-address and reply-to address details on the Message tab, BEFORE you click "Save Changes".
- Usually the default settings on the Logging and Advanced tabs do not need to be modified.
- Finally, on the plugin home screen click the "Send a Test Email" link to verify that your settings are correct and your emails are working.
- Check your inbox, and smile. Setup is complete!
Bonus step - integrate with SendGrid
SMTP is instantly better than WordPress/PHP mail. But it has its limitations. Every email provider has caps on the number of emails you can send per hour and per day. This means you most likely cannot send batch emails. Your limits will depend on your email provider. Here's a great compilation of email hosts and their limits.
For maximum deliverability without limits, integrate with SendGrid or a similar SMTP service. Personally I use SendInBlue. Their entire systems are built with email delivery in mind, and optimized to ensure that your messages reach their destination every time.
Our next tutorial will give a step-by-step setup guide to connect your WordPress emails to the SendGrid transactional email service.
* Source HERE