[UPDATED] How to Send WordPress Emails With Gmail in WP Mail SMTP

0 0

Do you want to use Gmail SMTP in WordPress?

Sending WordPress emails through Gmail helps to improve deliverability and stop your WordPress emails from going to spam.

We’ll walk through the process of setting up Gmail SMTP securely in this guide:

  1. Install WP Mail SMTP
  2. Create a project in Google Cloud Console
  3. Switch from Testing to Production (free Gmail accounts only)
  4. Connect WordPress site to Gmail
  5. Set up your From Email and default Gmail alias
  6. Enable email logging in WordPress
  7. FAQs and troubleshooting

First, let’s understand how we’re going to link your WordPress site to Gmail SMTP.

How Do I Link My WordPress Email to Gmail?

You can use WP Mail SMTP to link your WordPress email to Gmail via:

  • Gmail SMTP details
  • Google API

We highly recommend that you use the Google API. This method takes a little longer to set up, but it’s worth it for the extra security, because:

  • There’s no need to share your Google account password
  • You don’t need to allow less secure apps in your Google account
  • You don’t need to type your Google SMTP or account login details into WordPress.

The WP Mail SMTP plugin has a setup wizard that makes it easy to connect your WordPress site to the Gmail API. We’ll show you how to do it in this article.

Why Use WP Mail SMTP?

WP Mail SMTP lets you send WordPress email through Google SMTP or the Google API. Either of these methods is more reliable than using the PHP mail function, which is the WordPress default.

Many email servers have learned to block emails sent via PHP mail. Emails that are generated this way ‘look’ like spam. They don’t have any authentication in the header of the email, which is the technical part that we don’t normally see.

With WP Mail SMTP, you can authenticate emails through your Gmail or G Suite account to keep your login details safe and private.

WP Mail SMTP will also work for you if:

  • SMTP ports are blocked, which is a common problem on some hosting providers and Amazon EC2
  • You’re using localhost and you want to send email from your site
  • Your hosting provider isn’t configured to use PHP mail for some other reason.

Let’s go ahead and take a look at how to set up WP Mail SMTP to send emails through the Gmail API.

How to Send WordPress Emails Using Gmail SMTP with WP Mail SMTP

This step-by-step guide will show you how to set up the Google API for WordPress SMTP.

The whole process can take a while. We recommend keeping this guide open in a tab so you can follow the steps as you work through it.

If you’re not sure that you want to tackle this yourself, keep in mind that WP Mail SMTP Elite comes with a full White Glove Setup service for Mailgun or SMTP.com.

Step 1: Install WP Mail SMTP

The first thing you need to do is to install and activate the WP Mail SMTP plugin.

For step-by-step instructions, you can check out WPBeginner’s guide on how to install a WordPress plugin.

When you activate the plugin, the setup wizard will open. Click Let’s Get Started to begin.

Next, you’ll be asked to select your mailer. Go ahead and click Gmail.

WP Mail SMTP will show you a notification about the limitations of using Gmail with WordPress.

One issue to keep in mind is that Gmail and G-Suite both have account-wide email sending limits.

Google Account Type Email Sending Limit (per day)
Google (free) 500
G-Suite / Google Workspace 2000

These limits apply across your entire Google account. So any emails sent from Google Forms (and the regular emails you send) will count towards this cap.

So, what does this mean? If you have a busy website or a WooCommerce store, you may run into issues because the API isn’t designed to handle lots of transactional emails.

If you’re happy to continue, let’s keep moving through the setup steps.

On the next screen, WP Mail SMTP will prompt you for 2 things:

It’ll also display the Authorized Redirect URI, and we’ll need to copy that in a minute.

For now, pause the setup. At this point, we’ll set up your new Google Cloud app.

Step 2: Create a Project in Google Cloud Console

Now we’re ready to switch over to Google and set up the new app. This will create an API connection that you can use in WP Mail SMTP, and it means you never have to reveal your account username and password.

Start by opening up the Enable an API screen in Google Cloud Console. (Clicking this link will take you directly to the Enable an API screen in a new tab.)

You may be asked to agree to the Terms of Service if it’s your first time using Google Cloud Console.

Next, from the dropdown, select Create a Project and click Continue.

You may see a slight pause and see an Enabling API popup.

When the next screen loads, click Go to Credentials.

Now we can set up the credentials for your app.

As you move through the rest of these screens, be sure to click Next at the end of each section. If you click Done, you will exit the set-up process without completing it.

Credential Type

Now we’ll tell Google how to set up the API.

Under Which API are you using, go with the default selection: Gmail API.

Then scroll down a little to What data will you be accessing?

Go ahead and select User data and click Next.

Next, we need to set up a consent screen. Nobody will ever see this, but we need to do it before we can publish your app.

Click Next to move on.

Now we’ll set up your App Information.

The details in this form aren’t super important because nobody else will be using your app. Here’s what we suggest:

  • Type in an Application name that makes sense to you
  • Pick your email from the User support email dropdown
  • You can safely skip the logo.

In the Developer email field, type your own email address.

Now hit Save and Continue to move on to Scopes.

Scopes

Scopes aren’t required for your app, so we don’t need to use this section.

Scroll past the entire section and hit Save and Continue again.

Now we’re ready to set up the Client ID.

OAuth Client ID

In this section, we’re going to set up the Client ID that we need for WP Mail SMTP to connect to your Google account.

In the OAuth Client ID dropdown, select Web application.

You can change the Name if you want, but it’s fine to keep the default.

In the next 2 fields, you’ll want to type in the following information:

  • Authorized JavaScript origins: Type your site URL starting with http:// or https://
  • Authorized redirect URI: paste in https://connect.wpmailsmtp.com/google/

Hit Create to complete this step.

When Google prompts you to download your credentials, you can skip past it and click Done.

If you’re using a free Gmail account, be sure to complete the steps in the next section to avoid issues with your new app.

Step 3: Switch From Testing to Production (Free Gmail Accounts Only)

If you have a free Gmail account, Google will have published your app in Testing mode.

It’s super important to change this setting.

If you skip this step, your Gmail integration may stop working every week. You may also see the message Token has been expired or revoked in WP Mail SMTP.

We’re going to edit your app to put it into Production. Google Workspace users don’t need to do this.

To switch from Testing mode to Production mode, click the OAuth Consent Screen in the left hand navigation pane.

Under Publishing Status, click Publish App.

You’ll see the message Your app will be available to any user with a Google Account.

Don’t worry! Your account is secure.

No other user knows your Client ID and Client Secret, so they won’t be able to access your app. And WP Mail SMTP never asks for your Google username and password, so it’s completely secure.

When you’re ready to proceed, click Confirm.

And that’s it! Your app is now live in Google Cloud Console.

Step 4: Connect WordPress Site to Gmail

Now we can switch back to the WP Mail SMTP tab and complete the setup wizard.

Under Authorization, click Connect to Google.

This will open a login screen for Google. Go ahead and log in, then click the Allow button to grant permission for your site to send email.

You’ll see a popup confirming that the authorization worked.

Scroll all the way down to the bottom of the screen for the final step.

Step 5: Set Up Your From Email and Default Alias

WP Mail SMTP gives you the option of forcing all plugins and contact forms to use the same From Name if you want to.

This is a quick and easy way to make sure your customers and visitors always see the same Name in the sender field of every email.

You don’t have to force this setting. You can choose to enable it here if you want to.

Below that, there’s a From Email setting, and WP Mail SMTP will automatically show you all of the aliases set up on your Google Workspace or Gmail account.

The email address you pick in the dropdown here will be the default From email in WordPress.

You can use any email listed here to send email from WordPress. Just manually type it in as the From Email in your plugin or contact form settings, and WP Mail SMTP will authenticate the email for you.

The ‘primary’ email address that you selected will be used as a fallback. For example, if you type in an email that isn’t a registered alias in your Gmail account, WP Mail SMTP will default to this one.

Want to add more Gmail aliases here? Check out how to send WordPress emails from a Gmail alias for a complete guide to setting them up.

We’re almost done! Just 1 more option to check.

Step 6: Enable Email Logging in WordPress

WP Mail SMTP Pro includes complete email logging for WordPress.

At the end of the setup wizard, users of the Pro license or higher will see the option to turn this on.

You can use the built-in email logging tools to:

  • Track every email sent from your WordPress site
  • Search and track the delivery status of any email
  • Search, filter, and print email logs or save to PDF
  • Export email logs to CSV or XLS
  • View a deliverability chart on your WordPress dashboard.

When you confirm, WP Mail SMTP will do a final check on your settings and automatically send a test email to your chosen address.

And that’s it! You successfully set up your WordPress email with Gmail and WP Mail SMTP!

Create Your WordPress Form Now

Gmail SMTP FAQs and Troubleshooting

Occasionally, our users run into issues with Gmail SMTP in WordPress. Here’s a quick collection of FAQs that will help to resolve any issues that you have.

What Do Testing and Production Mean in Google Cloud Console?

In Google Cloud Console, Production means that your app is live. This is the default setting for Google Workspace users. Testing is the default setting for free Gmail accounts.

While Testing mode will work, it has a 7-day timeout. So every week, your emails will stop working and you’ll have to reconnect the app.

To fix this, put your app into Production mode.

What Do the Options “Internal” and “External” Mean?

In Google Cloud Console, Internal means that the app will be available to your organization. This is the default setting for Google Workspace users.

External means that the app will be available to any Google account. This is the default setting for free Gmail accounts because they aren’t part of an organization.

You don’t need to worry about this setting. You can go ahead and use the default that Google selects for your account.

Why Can’t I Use My Domain For the “Authorized Redirect URI”?

The Authorized Redirect URI is only used when you connect your site to Gmail the first time. We provide our own URL for this initial connection so that you don’t experience any issues with security plugins or mod_security on your server.

Why Do I See a DMARC, SPF, or DKIM Warning?

WP Mail SMTP has a built-in Domain Checker. It automatically scans your domain’s DNS records for rules called DMARC, SPF, and DKIM and will warn you if they are missing.

If you’re using Google Workspace or a custom domain with Gmail, we recommend adding these to your DNS. Jump down to our table of common Gmail errors for instructions.

Free Gmail users (without a custom domain) can ignore these warnings. As a free Gmail user, you don’t have control over the sending domain’s DNS, so you can’t add these records.

Why Do Emails From WordPress Appear in the Sent Folder in Gmail?

When WP Mail SMTP sends email using the Google API, it’s essentially the same as you sending them yourself from your ordinary mailbox. So every email that’s sent from your site will appear in your Sent Mail folder in your mailbox as well.

If you don’t want this to happen, we recommend that you choose a different mailer like SMTP.com or Sendinblue.

How Do I Switch Gmail Accounts in WP Mail SMTP?

If you want to send email from a different Gmail address in WordPress, you have 2 options.

Use a Gmail Alias

WP Mail SMTP lets you send emails from multiple Gmail or G-Suite aliases. So if you want to use a different From address, you can easily add it as an alias in your Google account.

To learn how to add an alias and use it in WordPress, check out how to send WordPress emails from a Gmail alias.

Switch Google Accounts

If you’d like to change to a different Gmail/G Suite email account, you’ll need go to WP Mail SMTP » Settings and click the Remove Connection button.

After disconnecting your account, scroll up to the Mail section and click Relaunch Setup Wizard to create a new Gmail SMTP connection.

Now let’s list some common error messages and solutions in case you run into a different problem.

Gmail Error Messages + Solutions

Error Message Solution
Invalid grant

Token has been expired or revoked

Your Google app is likely still in Testing mode. While this will work, your connection will break every 7 days.

To fix this, it’s easy to put your app into Production mode.

401. That’s an error.
Error: invalid_client

400. That’s an error.
Error: invalid_request
Missing required parameter: client_id

Head to WP Mail SMTP » Settings and click the Launch Setup Wizard button. Copy the Client ID in again.

Check that there’s no whitespace or extra text at the start or end of the Client ID.

cURL error 60: SSL certificate problem Contact your site’s hosting provider to ask them to install this certificate. It’s most likely the cacert.pem certificate, though it’s best to ask your host to check.
401
Login Required
Head to WP Mail SMTP » Settings and click the Launch Setup Wizard button. Run through the Setup Wizard again and be sure to connect your Google Account to WP Mail SMTP.
Request is missing required authentication credential.
Expected OAuth 2 access token, login cookie or other valid authentication credential.
This means your Gmail setup is not complete. Head to WP Mail SMTP » Settings and click the Launch Setup Wizard button to check your settings.
This app isn’t verified To bypass this message, you’ll need to click Advanced and then Proceed.

Don’t worry – your app does not need to be verified by Google to work. The message is referring to the app you created (so you are the developer in this case).

Action Needed: It doesn’t look like the SPF record required by Google has been added to your domain.
Please check out Google’s SPF guide for details on how to add this record to your domain’s DNS.
WP Mail SMTP can’t find an SPF record in your DNS. Adding an SPF record could help improve email deliverability.

If you’re using Google Workspace or a Gmail account with a custom domain, follow Google’s tutorial to solve this.

If you’re using a free Gmail account, you can ignore this warning.

Action Needed: It doesn’t look like the DKIM record required by Google has been added to your domain.
Please check out Google’s DKIM guide for details on how to add this record to your domain’s DNS.
WP Mail SMTP can’t find a DKIM record in your DNS. Adding a DKIM record could help improve email deliverability.

If you’re using Google Workspace or a Gmail account with a custom domain, follow Google’s tutorial to solve this.

If you’re using a free Gmail account, you can ignore this warning.

Action Recommended: It doesn’t look like DMARC has been set up on your domain (example.com).
We recommend using the DMARC protocol because it helps protect your domain from unauthorized use.
Please check out our step by step guide for details on how to add this record to your domain’s DNS.
WP Mail SMTP can’t find a DMARC record in your DNS. Adding a DMARC record could help improve email deliverability.

If you’re using Google Workspace or a Gmail account with a custom domain, read how to add a DMARC record to your domain. This article includes a generic DMARC example you can copy and paste.

If you’re using a free Gmail account, you can ignore this warning.

If your error message isn’t listed here, you can contact WP Mail SMTP support:

Create Your WordPress Form Now

Next, Grow Your Website Traffic

Now that your emails are sending perfectly, it’s time for explosive website growth. You can start by hosting a giveaway on your website and trying some easy tips to reduce form abandonment.

Ready to build custom WordPress forms? Get started today with the easiest WordPress form builder plugin. WPForms Pro includes 100+ free templates and offers a 14-day money-back guarantee.

If this article helped you out, please follow us on Facebook and Twitter for more free WordPress tutorials and guides.



Source link

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More