BACK TO TOP

How to Send WordPress Emails with the Gmail SMTP Server

How to Send WordPress Emails with the Gmail SMTP Server

Emails are one of the most common ways to engage with website users and convey information in general. However, if you are managing a WordPress website, chances are high that you have experienced some mailing issues. It could be that the emails aren’t being delivered or that they are wrongly marked as spam. These emails are called transactional and include user account notifications, password reset emails, contact form notifications, or other product-related emails, among others.

These emails are vital to smooth business operation, which makes it important to tackle any errors as soon as they appear. In this article, we will discuss why email issues occur and how to tackle them using the SMTP mailing protocol. Furthermore, we will discuss the benefits of using the Gmail SMTP server as your SMTP mailer of choice and how to properly set it up. To help you navigate this topic, we’ve broken it down into several smaller steps:

Advantages of using the Gmail SMTP server for WordPress emails

WordPress mailing issues happen most often because of the default wp_mail() function used by WordPress to send emails. Some hosting providers aren’t configured to use this function, meaning your WordPress emails won’t be sent at all, while other hosting providers implement heavier restrictions by adding email authentication. As a result, WordPress emails that use this default function are more likely to end up in spam because of problematic email headers. If your WordPress emails are often marked as spam, certain email providers may choose to block them, which is a significant concern for WordPress website owners using shared hosting.

To avoid all those WordPress mailing problems, we advise using SMTP. SMTP or Simple Mail Transfer Protocol is the most efficient email delivery method currently available. It includes a website authentication method that gives more legitimacy to the sender, which can significantly increase email deliverability. The SMTP protocol can be implemented using custom code or with a suitable WordPress plugin that integrates a third-party mailing service. As plugins are easier to implement for users of all knowledge levels, we have opted to show you the latter. And in the following sections, we’ll guide you through integrating the Gmail SMTP mailing service with WordPress.

The reason we picked the Gmail SMTP service is that it allows users to send up to 500 emails per day with a free Gmail account, and up to 2,000 per day with a paid G Suite account. That amount of free emails per day is greater than any other currently available SMTP mailer and it is more than sufficient for any small to medium WordPress website or blog. If you don’t fall into that category, you should carefully review other SMTP mailing services to find the one that works best for you. Some of them will be included as the mailing options within the plugin we decided to cover.

Additionally, Gmail doesn’t require you to insert your password as a form of verification but uses the OAuth 2.0 authentication method, which makes the whole process more secure. This also makes it a bit more complicated than any other SMTP mailer option. Nevertheless, we have carefully covered all the steps below so you should have no trouble implementing the steps on your end.

Qode Themes: Top Picks
Bridge New Banner
Bridge

Creative Multi-Purpose WordPress Theme

Stockholm WordPress Theme
Stockholm

A Genuinely Multi-Concept Theme

Startit WordPress Theme
Startit

Fresh Startup Business Theme

How to send WordPress emails using the Gmail SMTP server

Now that we covered why using the Gmail SMTP server for sending WordPress emails is a great option, let’s take a look at how to do that. For this article, we will guide you through the process using the WP Mail SMTP plugin, which is pretty popular in the WordPress community.

The WP Mail SMTP plugin is the most used WordPress SMTP plugin at the moment. It allows you to integrate your website with the most popular mailing services (SMTP.com, Sendinblue, Gmail, Amazon SES, and others). It is a freemium plugin with extensive documentation and a wizard to help you with the setup process. The premium version unlocks additional features like email logging, managing WordPress emails and notifications, multisite settings, premium support, and a “white glove” setup service.

Using the Gmail mailer option

After installing the plugin, navigate to WP Mail SMTP > Settings. This will place you within the General tab, where you should examine the available settings. Then, insert the sender email address in the From Email field and the sender name in the From Name field. By default, the From Name field will already contain your website’s name, but you can change that now if you want.

WP Mail SMTP Settings

Additionally, there are other settings you can enable, but as they depend on individual preferences and aren’t necessary, we won’t cover them. However, please note that the return path option isn’t supported for the Gmail mailer. As such, it will be disabled upon selecting Gmail as the mailer option.

Now, let’s proceed to the most important section—the mailer options. To send WordPress emails using the Gmail SMTP server, choose Gmail as your mailer option. This will make the subsequent options appear for the appropriate mailer.

As you can see from the screenshot below, you will need to create two things to finish this process—client ID and client secret. And then you will need to pass the authorization check. Don’t forget to save your chosen settings by pressing the Save Settings button at the bottom.

Gmail Mailer
Gmail Mailer Save Settings

The following step involves creating a web application inside the Google Cloud Platform with the appropriate credentials for the authorization process. But, before we jump into that, we want to address two things.

Firstly, you shouldn’t be alarmed if you can’t see the From Email value after saving the Gmail mailer choice. The option isn’t lost, it simply becomes disabled until you successfully create the web application in this step and it is restored afterward.

Secondly, as you can see on the screenshot above, there are other methods of connecting to Google SMTP that are less secure. One of those methods is also available with the WP Mail SMTP plugin and you can enable it by choosing the Other SMTP mailer option. However, as this method requires you to enable less secure apps in your Google account and insert your Gmail password for authorization purposes, we won’t be using it. For anyone who’s interested, we suggest reviewing the plugin’s documentation, especially the part on setting up the other SMTP mailers.

With that being said, let’s carry on with this step. We suggest keeping the current tab with the plugin settings open and conducting all the remaining steps in a separate tab. This will save you a lot of time as some steps require copying and pasting information from one tab into the other.

For starters, navigate to the Google Cloud Platform and log in with your credentials. Then, you need to create a new project. If you haven’t created any projects previously, the Create project button will be at the top of your Google Cloud Dashboard. Click on this button to create your new project.

Gmail Mailer Create Project Button

Set the project name and click on the Create button below. If you want, you can also edit the project ID and assign a parent organization or folder to this project.

Gmail Mailer Project Name

If you previously made projects within the Google Cloud DashboardPlatform, then you need to click on the dropdown link next to one of your existing projects. This will open a popup window where you need to click on the New project button.

Gmail Mailer Select a Project

At this point, you’ll see the same page for creating a new project and you can proceed as mentioned above. A word of advice, make sure to pick an obvious project name so you can easily find it among other projects later on. Once you’ve made your project, navigate to APIs & Services > Library.

Gmail Mailer Library

On the following page, locate the Gmail API (it will be in the Google Workspace section) and click on it. If you need help locating it, you can also use the search feature that is included at the top of the page.

Gmail Mailer Gmail API

On the following page, click on the Enable button to enable the Gmail API.

Gmail API Enable

Next, click on the Create credentials button, located near the top of the Overview tab within the Gmail API.

Create Credentials

The first step is to define your credential type. To do so, select Gmail API as the API you are going to use and tick User data as the data you will be accessing. Click on Next to save these choices and proceed to the next step.

Credential Type

Then, insert the app name and add a user support email where users can contact you regarding their consent. Also, make sure to insert the developer’s email address below. You can also upload an app logo image, if you like. Whereas the first three settings were mandatory, uploading an image isn’t, so we decided to skip it in our tutorial. To confirm your choices, click on the Save and Continue button below.

App Information

The third step in creating the API credentials involves setting the optional scopes. As those will be set by the WP Mail SMTP plugin, you should simply skip this step by clicking on the Save and continue button at the bottom.

Save and Continue

After this, you need to create the OAuth Client ID. To do so, select Web application as the application type and insert a name for it below. You can call it whatever you like as this name is only used to identify the OAuth 2.0 client and it won’t be visible to end-users. Then, insert your website’s URL inside the Authorized JavaScript origins > URIs option. Make sure to insert it without the trailing slash.

Afterward, return to the tab with the plugin settings, find the Authorized redirect URI option, and copy it (there’s a helpful copy button next to it). Then, return to the previous tab. Paste this URL inside the Authorized redirect URIs > URIs option and click on the Create button at the bottom.

Copy URI
Paste URI

Once you’ve done that, the OAuth client credentials will be made. You can download the complete credential information as a JSON object by pressing the Download link. However, as we only need the client ID and client secret, we can just click on the Done button below.

Done Button

After that, locate the client ID you created earlier on the OAuth 2.0 Client IDs list and click on the Edit icon next to it.

Edit Icon

The aim here is not to edit the information; instead, this action will help us copy the client ID and secret that can be found on the edit page, in the top right corner.

Client ID and Client Secret

After copying the data, make sure to close the web application edit page by pressing the Cancel button near the bottom of the page.

The copied client ID and client secret data should be pasted inside the corresponding plugin options. Once you’ve done that, click on the Save Settings button at the bottom to save that data.

Client ID and Client Secret Paste

Completing all the steps so far will give you access to the authorization button. Then, to confirm the authorization process, press the Allow plugin to send emails using your Google account button.

Authorization

In the following window, you will be asked to choose a Gmail account that will be used for the authorization process of the web application you made in previous steps.

Choose an Account

After selecting your Gmail account you might see a warning screen similar to the one below, stating that Google hasn’t verified the app yet.

Hide Advanced

This is nothing unusual and you should simply proceed and click on the Advanced link. Then, click on the Proceed to wpmailsmtp.com link. After that, you should give wpmailsmtp.com the necessary permissions to edit Gmail emails (read, compose, send and permanently delete). This is done by ticking the checkbox next to the permissions you are giving and clicking on the Allow button below.

Confirm Choices

Once you’ve done that, you will be redirected to the plugin settings screen. In there, you will see a success message near the top stating that you have successfully linked your website with the newly created Google API project.

Successfully Linked

With this, the plugin configuration process is over. The only thing that remains is to test the mailing process, and we’ll guide you through it in the following section.

Testing the Gmail SMTP mailing

To test the Gmail SMTP mailing process, you should navigate to WP Mail SMTP > Settings and open the Email Test tab. To send the test email, insert the recipient address in the Send To field and press the Send Email button below.

Send Email

If you properly completed all the previous steps, then you should see a success message similar to the one shown below.

Test Email Sent

Nevertheless, you should check your inbox as well. The test email should look similar to the one shown below.

WP Mail SMTP

Make sure to check both the sender name and email settings to verify that they correspond to the ones inserted in the plugin settings.

Troubleshooting errors during setup

During the configuration process for your Gmail SMTP WordPress emails, you might encounter various issues. However, you shouldn’t let that discourage you as the WP Mail SMTP plugin has very thorough documentation. We strongly advise reviewing the plugin’s FAQ section to get an overview of what possible errors you could encounter and how to solve them. It covers all the frequent errors you can get both during the configuration process and the email testing process.

On our end, we experienced the 403 authorization error during setup. While this is just one of several possible errors, we decided to share how we dealt with it in the final part of the article.

After choosing a Gmail account that will be used for your web application’s authorization process, you might get an authorization 403 error. If this happens, you shouldn’t worry.

Authorization Error

The Google Cloud Platform Console Help section on setting up your OAuth consent screen provides the following explanation of the error:

“An org_internal authorization error is displayed when authorization is requested from users outside the Google Cloud project’s parent.”

Therefore, the simplest solution to this problem is to make the web application external instead of internal, which is its default setting. Internal web applications can configure internal members that the authorization is limited to, whereas external applications are available to any user with a Google account.

To make the web application external, navigate to the OAuth consent screen tab and click on the Make external button.

Make External

In the popup window that opens, set the publishing status to In production and click on the Confirm button to make the application external.

We would like to draw your attention to the notice below the In production option. While you don’t need to submit your app for verification now, if you change some of the information in the future, you will need to get it verified. Having said that, let’s move on.

Make External Confirm

Afterward, repeat the authorization process as described above.

Final Thoughts

A frequent cause of mailing issues for WordPress websites is the default wp_mail() function. The easiest way to avoid this problem is by switching to the SMTP protocol and sending your WordPress emails via a dedicated server. Using SMTP will improve the deliverability of your emails and help you maintain steady business and website operation.

To that end, we covered how to connect your website to the Gmail SMTP server using the WP Mail SMTP plugin. And we explained how to create a web application in Google Cloud Platform as well as the OAuth client ID and secret which are used for the authorization process. Even though the whole configuration process might be lengthy, we took care to cover the process step-by-step. Additionally, the plugin we chose includes thorough documentation which can help you with any doubts or issues you may run into. Now all you have to do is carefully follow our guide and your Gmail SMTP server setup for WordPress will be done and dusted.

Post your comment

Comments0