Would you like to use your Gmail or G Suite account to fix delivery issues on your site? WP Mail SMTP’s Gmail option uses Google’s API to securely authenticate your site’s emails, and to help them get delivered successfully.
In this tutorial, we’ll show you how to set up WP Mail SMTP using the Google mailer with your Gmail or G Suite email address.
- Installing and Configuring the WP Mail SMTP Plugin
- Creating a Web App in Your Google Account
- Granting Permissions and Sending Test Email
- Frequently Asked Questions
1. Installing and Configuring the WP Mail SMTP Plugin
Before getting started, you’ll need to install and activate the WP Mail SMTP plugin.
Once you’ve got the plugin installed, you’re ready to configure the plugin’s settings. You can find these settings under WP Mail SMTP » Settings, and we’ve outlined each option below:
This is the email address that all of your site’s emails will be sent from. Once you’ve connected your Gmail account, you can select the email address you’d like to use (including any aliases you’ve configured) from the dropdown that appears.
Note: In order to use multiple Gmail aliases throughout your WordPress site as the From Email address, make sure the Force From Email box is left unchecked.
Below the From Email, you can set the From Name. This is the name associated with the emails your site sends out. By default, this will be set to your site’s name, but you can adjust this to any value you’d like. You can also check the Force From Name option to apply this setting site-wide.
You can leave the Return Path setting as is, as Gmail doesn’t support this functionality (later on, you’ll notice this field becomes disabled).
This is where you can choose which mailer you’d like your site to use. To configure the Gmail mailer, you’ll need to select the Gmail option.
Once you’ve chosen this mailer, you should see a new section appear titled Gmail. Under this, there will be settings named Client Secret and Client ID.
To generate the information needed for these fields, you’ll need to use your Google account to create a web application. This process doesn’t require any coding, and we’ll show you exactly what to do in the next step.
We’ll be coming back to WP Mail SMTP’s setting page a little later, so for the next step you’ll need to open a new tab or window in your browser.
2. Creating a Web App in Your Google Account
In the new tab or window you’ve opened, you’ll need to sign into your Gmail account and access Gmail’s application registration.
Note: If you’re using G Suite, make sure that the Google account you use has email sending permissions (in other words, access to its own inbox).
Once you’ve logged into your Gmail account, you’ll see a form named Register your application for Gmail API in Google Cloud Platform.
For the Select a project where your application will be registered step, a new app will automatically be created for you in Google if you haven’t previously created one. Click on the Continue button.
You may be asked to agree to the Terms of Service if it’s your first time using Google Cloud Console.
Go ahead and agree to the Terms of Service, and select your Country of Residence from the dropdown menu. If you’d like, you can also optionally choose to receive newsletters from Google Cloud, however this is not required.
After you’ve configured each of these settings, go ahead and click the Agree and Continue button to move on to the next step.
Once you’ve clicked this button, you’ll see a confirmation message that says The API is enabled. To move forward to the setup page, go ahead and click the Go to credentials button.
Create Your Application’s Credentials
On the next page, you’ll be asked a few questions to help Google determine the credentials you need.
In the first step titled Credential Type, you should make sure the Gmail API is selected in the Which API are you using section. Under What data will you be accessing, select the User Data option and click on Next.
Note: If you don’t see an option for the Gmail API in the dropdown, be sure that you have the Gmail API enabled for your account.
Configuring Your OAuth Consent Screen
In this second step, Google will ask for some basic App information. This isn’t very important, since nobody else will be using your app, but some fields are still marked as required:
- App name – Input the app name of your choice, for example: WP Mail SMTP
- User support email – Select your email address
- App logo – Skip this option
Finally, add your email address in the Email addresses field and click on Save and Continue.
Scroll down to the end of the Scopes section and click on Save and Continue. This section is optional, so we are skipping it.
OAuth Client ID
In the Application type dropdown menu select the Web application option. The OAuth Client ID step will update after you make your selection.
You can leave the Name default value or change it to something more relevant, for example: WP Mail SMTP.
Click on the Create button to complete this step.
At this point you are done with the Create credentials setup, so you can click on the Done button. Don’t worry about saving or copying the Client ID, we’ll do that a bit later.
Update publishing status from Testing to Production
This step is only for users with free Gmail accounts. Users with Google Workspace (formerly G Suite) accounts should skip this step.
Google will put your app into Testing mode by default. It’s really important that you switch to the Production mode, otherwise, your app will be super limited and will not function properly.
In the left side menu click on the OAuth consent screen.
In the Publishing status section you will see that the app is in Testing mode. Click on the Publish App button, to switch it to the Production mode.
A popup will show up with the “Your app will be available to any user with a Google Account.” message. Don’t worry, you are the only one that will have access to this app. This app will only be used in your WordPress site (in the admin dashboard area). Click on Confirm button.
3. Granting Permissions and Sending Test Email
In the left side menu go to the Credentials page. In the OAuth 2.0 Client IDs section you can now see the details of the web application you just created. To view Client ID and Client Secret, click the pencil icon.
This will open all of the details for your app. On this page, you’ll see the Client ID and Client secret values.
Go ahead and copy both of these values into your WP Mail SMTP settings. Once those have been added, click Save Settings at the bottom of the page.
Note: Be very careful not to copy any extra text or spaces with your Client ID or Client Secret, as this will result in an error in the next step.
After saving these settings, the page will refresh. You must grant permission before Google allows our plugin to use your Gmail API to send emails.
To do this, scroll to the bottom of this page and click the button labeled Allow plugin to send emails using your Google account.
This will open a login screen for Google. Go ahead and log into the account you’re setting up SMTP with.
If you are connecting with a free Gmail account you might see the below screen. Google Workspace (formerly G Suite) users will not see it because their app is configured for internal use only, a setting, which is not available for free Gmail users.
Click on the Advanced link in the bottom left corner. In this expended section click on Go to wpmailsmtp.com (unsafe). Don’t worry, Google only displays this warning, because the app is not verified by them. There is no need for the app to be verified since you created this app just for your own use.
Next, you’ll see a screen asking for permission for this site to send emails on your behalf.
When you’re ready, click the Allow button to proceed.
Next, you’ll be returned to your WP Mail SMTP settings and a success message will be displayed. Now that the connection is complete, you’re ready to send a test email under the Email Test tab.
Once the Test Email tab is open, you’ll need to enter a valid email address and click the Send Email button. Be sure to use an email address you have access to so you can confirm the email is delivered.
When the test message has been sent, you’ll see a success message at the top of this tab.
You should also soon receive a test email at the email address you entered.
Frequently Asked Questions
What If the Test Email Doesn’t Send Successfully?
If the SMTP test email isn’t able to send, a debug log will appear with additional details. Here are some of the possible error messages and how to resolve them.
401. That’s an error.
This error appears when the Client ID isn’t able to be read properly. To fix, try copying the Client ID in again and check that there’s no whitespace or extra text.
400. That’s an error.
Missing required parameter: client_id
This error will display when the Client ID field is empty or not able to be read properly. To fix, copy in the Client ID again and be careful to not add extra text or whitespace.
cURL error 60: SSL certificate problem
This message means that the server is missing a certificate that’s required for SMTP to work. To fix, you’ll need to contact your site’s hosting provider to ask them to install this certificate (most likely the cacert.pem certificate, though it’s best to ask your host to check).
“message”: “Login Required”
If you see this in the debug message, permission still needs to be granted to your Google account. For instructions on how to fix this, please see Step 3 of this tutorial. Also, be sure to check that the From Email in your SMTP settings matches the email used to setup the Google app.
Request Entity Too Large
If you’re seeing this error, it’s likely that files being sent through your forms exceed Gmail’s limit for direct file attachment in emails. This limit is applied to the sum of the message’s text as well as the encoded attachment. To prevent this error, you’ll need to make sure that all files are no larger than 22 MB.
There was a problem while retrieving Auth for gmail: Could not json decode the token
This error is a possible indicator that another plugin (such as UpdraftPlus) is loading a different version of Google’s API on the site, creating a conflict. If possible, the conflicting plugin should be deactivated. Otherwise, it’s recommended that you set up another mailer.
If none of the above apply, or the test email still isn’t working
Your Google account may have the Gmail API disabled. To check on this, follow Google’s guide to enabling an API.
If the Gmail API is enabled, after following those steps you should see a small green checkbox labeled API enabled.
What If I See a Screen Saying “This app isn’t verified”?
When you click the Allow plugin to send emails using your Google account button, Google might display a screen that says “This app isn’t verified. This app hasn’t been verified by Google yet. Only proceed if you know and trust the developer.” There’s no need to worry, though — the message is only referring to the app that you just created in your own Google account (so you are actually the developer in this case).
To bypass this message, you’ll need click Advanced and then Proceed.
What If I Want to Switch to A Different Email Later?
If you’d like to change to a different Gmail/G Suite email address, you’ll need to repeat all tutorial steps above. This includes generating a new Client ID and Client Secret under this other email account.
When you get to the Authorization step (under Step 3), save your settings and then click the Remove Connection button. This will remove the authorization for your original email account and allow you to repeat the authorization steps with the new email.
Does the Gmail Mailer Support Aliases?
Yes, as of July 2020, Gmail aliases are supported in WP Mail SMTP. For more details on how to set up an alias in Google, check out their guide on how to send emails from an alias.
Can I use this if I have 2 Factor Authentication (2FA) enabled on my Google account?
You can definitely use 2 Factor Authentication with WP Mail SMTP’s Gmail option. However, it’s important to note that if you choose to disable 2FA, or change the password on your account, you’ll need to go through the setup process again.
When authorizing my app, I get an error message:
Error 403: access_denied. The developer hasn’t given you access to this app.
This message means that your app’s permissions are set to the testing mode in the Google app.
To fix this, be sure to switch the mode for testing to production and try authorizing your app one more time.
Do I need to submit my app to Google for verification in order for it to work with WP Mail SMTP?
It isn’t required for you to submit your app for verification, however you’re welcome to if you’d like. If you choose to submit your app for verification, you can continue the authorization process in WP Mail SMTP, without waiting for Google’s verification.
That’s it! You’ve now set up WP Mail SMTP’s Gmail mailer on your WordPress site.
Next, would you like to know how to effectively troubleshoot issues within WP Mail SMTP? Be sure to check out our tutorial on how to troubleshoot WP Mail SMTP for more details.