Over the last couple of years, the amount of spam emails increased dramatically making it very difficult for email service providers to filter spam messages and protect their users from receiving thousands of unwanted emails. Unfortunately, methods for filtering out spam messages often affect all the automated emails sent from websites. To you, as an administrator of the website, this can be a reason for quite a headache. Luckily, this can be addressed with a bit of SMTP know-how and we’ll cover the most common method in this post.
What is SMTP?
SMTP stands for Simple Mail Transfer Protocol. It has been used all over the internet since the early 1980s and as such is quite a mature and robust protocol. Compared to WordPress’s default WP mail, it is much more reliable and provides much better deliverability. So, where email deliverability is paramount, SMTP is the way to go.
Using SMTP for sending emails from WordPress-based websites
Given that WordPress by itself does not offer setting up and using SMTP-based mails, we will need a third-party plugin for this in order to connect our WordPress website with the SMTP mail server of our choice. There are many SMTP plugins currently on the market and they all pretty much do the same thing. One of the most popular is certainly WP SMTP which we will be using as an example in this post. Now, in order to be able to send emails using the SMTP protocol, we will also need an email service provider that supports SMTP. In this case, we will be using Gmail as it is the most widely used and is quite reliable.
Configuring your Google account
First and foremost, we have to configure your Google account so that it can work with WP SMTP. To start, first, navigate and log in with your credentials to Google Cloud Console by clicking this URL. I recommend opening this in a new tab of your browser so that you can easily switch back and forth from there to the back end of your website as this will be needed afterward.
Once you’re logged in to Google Cloud Console, navigate to projects and then click New Project button. Once the new page appears, you will be prompted to enter the project name and select the organization. You can enter anything you like into both of these.
It will take a few seconds for the project to get created and once that is done, you should enable APIs and Services. To do this, click the hamburger menu in the top left (1), then click APIs and Services (2) and then click Library (3):
After the Library page loads, type into the search bar Gmail API. This should return a couple of results where you should click Gmail API as indicated on the screenshot below.
On the next page, you should click the Enable button:
This will take a few seconds to get enabled, after which you will be guided to the Gmail API page. Now, although a lot is going on on this page, the only thing we need here is the Create credentials button located in the top right corner.
By clicking this button, a new page will load where you should make sure that Gmail API is selected in the dropdown menu (1) and that you have selected User data (2) choice and then click the Next button (3)
On the next page, enter App name (you can enter anything you like), select your email address in the User support email, enter email address for developer contact information (any email address you want) and finally, click Save and continue
The next step is optional and does not play any significant role for our use, so we won’t be making any changes but will instead just click Save and continue button.
In the next step, you should first select Web application from the dropdown menu (1) and then enter the name (2) which can be anything you see fit. After that, go down to the Authorised redirect URIs (3) and click Add URI button and when the field appears, paste the following there: https://connect.wpmailsmtp.com/google/
When done, click Create button (4)
In the final step, you will be offered to download your credentials. However, this is not needed for now so you can simply click Done button to finish this part of the setup.
By default, Google will put your newly created app in internal mode. However, in order to be able to use it, you will need to switch it to external mode. To do this, click the hamburger menu in the top left, then select APIs & Services, click OAuth consent screen and in the User type area click Make external button. In the popup window that will appear, select In production option and then click Confirm button.
After this, click again Hamburger menu in the top left corner, select again APIs & Services and then click Credentials menu item. In the OAuth 2.0 Client IDs area, you will notice the web app that you have recently created. By clicking the pencil icon on the right…
…a new page will load where you will be able to access all of the credentials needed for setting up WP SMTP plugin to work with your Gmail.
After this, you are done setting up but don’t close this browser tab as you will need to access these credentials soon.
Setting up WP SMTP
The first thing you will need to do is to install WP SMTP plugin. As mentioned earlier, this plugin is free and is available in the WordPress plugin repository. So, if you simply navigate to the plugins area of your website and then click Add new button, you can just type in WP SMTP and it will pop up in the results from where you can install and activate it.
Once you finish the installation and activate the WP SMTP plugin a setup wizard will appear, which will make it easy for you to set it up. So, in this wizard, the first choice you should make is which SMTP service you would like to use, and since we will be using Gmail in this example, we will select Gmail here.
Now, when you select the Gmail option here, a popup will appear, letting you know that Gmail imposes some limitations. We will be covering these later in this post. For now, click I understand, continue button.
On the next screen, you will be prompted to enter your Google credentials which we have created while configuring the app in the Google Cloud Console. Specifically, you will need to copy the Client ID and Client Secret
The Authorized Redirect URI field should be left as-is, without making any changes, and should contain the following: https://connect.wpmailsmtp.com/google/
When done with copying and pasting Client ID and Client Secret values, click Connect to Google button. This will prompt you to log in to your Google Account and you should make sure that you’re logging in using the same credentials you have used previously to log in to Google Cloud Console and which is the same account you have created your web app with. It might happen at this point that a scary notification from Google will jump at you… such as this one for example:
But instead of giving up, you should click Advanced on the left hand side and then click Go to wpmailsmtp.com (unsafe) at the bottom.
On the next page, you will be notified that wpmailsmtp.com wants to access your Google Account, which is expected as we want to use WP SMTP with our Gmail account, so you should click Continue button here
After this step, you should be greeted with a Successful Authorization message, indicating that you have successfully connected WP SMTP with your Google Account.
When you click okay, you should then scroll all the way down and click Save and Continue button.
The next page will show you enabled features and will offer some extra, premium ones but none of this is needed at this point so you can just click Save and Continue button again.
In the finishing stage of the setup, WP SMTP will perform an automatic check to make sure that everything works fine after which you can click Finish setup button.
One thing to keep in mind
You would be quite right if you got the impression that setting up this is a lengthy process. We have tried here to condense everything and make it as easy as possible to follow. But with WP SMTP set up like this, emails sent from your website will have much better deliverability. One thing that you should know and which WP SMTP warned you about right at the beginning is the limited number of emails that can be sent via Gmail. At the moment, you can use a free Google account and send up to five hundred emails per day. For most, this will be sufficient. However, if you need more than this, you will have to upgrade your Google account to one of the premium tiers. This limitation, as well as Google’s policy changes quite frequently, so take this with a grain of salt if you’re reading this tutorial a few months after it has been released (January 2023) and before you start setting everything up, check the current state of Google’s limitations.