1. Home
  2. WordPress Tutorials
  3. How to Use the Gmail SMTP Server to Send Mail from WordPress

How to Use the Gmail SMTP Server to Send Mail from WordPress

gmail smpt server

Sending email from WordPress is a feature that some people take for granted. By default, the system uses the PHP function to send things like updates, password resets or notifications from various forms you may use. However, PHP isn’t always the best option. For one thing, it’s easier to be a victim of email fraud.

One viable option is to change the default PHP feature to something that is more stable. For instance, using Gmail offers stability as well as security when sending your messages.

In this tutorial, we’re going to show you how to take advantage of the Gmail SMTP server directly from WordPress.

Why Should You Change from PHP to SMTP?

Simple Mail Transfer Protocol, or SMTP, is the standard system when email is sent from an actual server. It uses authentication methods to verify user access and offers a layer of security when compared to basic PHP methods. This makes it more difficult to hack when compared to other aspects of your website.

Another aspect of PHP mail is that it will trigger various spam filters. Depending on the level of security a recipient employs, a spam filter will check the validity of email received by scanning through the server a message came from. If it’s unidentifiable by the filter, the message will be tossed aside.

Many people are leery about the messages they receive in today’s world. Making the email look as legitimate as possible can ease the minds of your recipients and may play a part in reducing how often your messages are deleted. It’s all about making the reader feel comfortable.

Using OAuth Protocol to Set Up Gmail SMTP from WordPress

While this procedure may seem a bit time consuming for some, it’s perhaps one of the most secure methods of using a Gmail SMTP server with WordPress. Luckily, the process isn’t that difficult to complete. To use this method:

Step 1: Go to “Plugins” from your WordPress dashboard, add a new plugin and search for Gmail SMTP.

Step 2: Install and activate this plugin.

gmail smtp plugin

Step 3: This will add a new feature under “Settings” in your WordPress dashboard labeled “Gmail SMTP.” Click on this link to open the plugin’s settings.

feature under settings

Step 4: At the top, you’ll notice a warning message about how you need credentials to set up your web application. Under this message and within the “Basic Setup Instructions,” you’ll see a link for “web application.” Click this link to open the Google website.

web applications link

Step 5: After signing into your Google Account if you haven’t already, a new page will load to “Register your application for Gmail API.” There will be a drop down list under this section. Make sure it’s set to “Create a project” and click the “Continue” button.

create project

Step 6: Once the project has been created, you’ll be taken to a new window for the Google Library. This is a list of the APIs you can use. Look for the “Gmail API” link located under the section for “Google Apps APIs.” Click the link.

google api

Step 7: You will be taken to a new window with a warning about how the API can’t be used until you create credentials. On the left side of your screen, you will see an area for “Credentials.” Click this area.

credentials

Step 8: The Credentials page will appear. Find the area labeled, “OAuth consent screen” and click it.

oauth consent

Step 9: Fill in the pertinent information on this page including any optional information you wish to display. Use the drop down list to find the email address you wish to use, which is usually already set to the account you’ve signed into Google.

pertinent information

NOTE: You must have a product name to show to users in order to use this function.

Step 10:  Click the “Save” button on the bottom to keep your OAuth consent information.

oauth consent information

Step 11:  You will now be taken to a page for creating a client ID. Click the first radio button in the list labeled, “Web application.”

web application radio button

Step 12:  A new field will appear to give your client ID a name. Use something that you will easily remember such as “Email Client.”

email client

Step 13:  Next is the “Authorized JavaScript origins.” Enter the URL of your actual website.

website url

Step 14:  In the field under “Authorized redirect URIs,” you will need to paste the URL that is displayed in the Gmail SMTP plugin settings. This is located just under the Basic Setup Instructions box.

authorized redirect url

Step 15:  Once this information has been entered, click the “Create” button at the bottom.

Step 16: A new pop-up window will appear with your client ID and client secret. Copy both of these strings and paste them into your WordPress Gmail SMTP plugin.

copy strings

Step 17: Click the “Ok” button on the pop-up once you’ve copied the strings.

NOTE: If you need these again in the future, you can go into the OAuth client in Google and edit the web application. Both ID and secret will be in this area.

Step 18: Go back to the WordPress plugin and complete the empty fields such as email address and “From name.”

Step 19: Keep the drop down for “Type of Encryption” on “TLS.”

Step 20: In the “Port” field, enter 587.

Step 21: Click the “Save Changes” button on the bottom of the plugin settings.

Step 22: A new button may appear under the “Save Changes” and will be labeled “Grant Permission.” Click this button.

grant permission

Step 23: Google will then ask for your permission to link the site to your Google account. Click the “Allow” button and you will be taken back to your Gmail SMTP settings window.

Step 24: Your email is now connected to the website through SMTP.

Can you use a free Gmail account, or should you pay for SMTP services?

There is nothing wrong with using a free account when you want to use a Gmail SMTP server. However, using the GSuite from Google adds a great deal of functionality. For instance, you can get custom email, 30GB of storage, spam protection, integrated video meetings and more for a low price. And that’s not including the other services that are part of the suite. It may be a good system to consider, especially if you operate a team environment.

What if this doesn’t work and you get an error when trying to send an email?

Some website hosting platforms may have issues when trying to use a different server other than their own when using Gmail SMTP. As a result, the username and password mail fail. If this happens, you will need to make a few minor adjustments in your cPanel.

Log into cPanel and create an email address the same as the one used in the credentials of your web application in Google.

cpanel

Go into your MX Records and change the routing from automatic to remote. There should be a link located next to MX that reads, “Email Routing: Remote Mail Exchanger.”

mx records

This essentially fools your website server into thinking you’re sending the message through it even though your really not. This may not work for everyone, but it may be a good place to start should you encounter problems.

Email is one of the most frequent pieces of communication on the Internet. Although the default PHP system in WordPress may work great in some instances, it may be hindering your success in others. Deliver stability and security to your website mail functions. It may just make a difference in how people interact with your messages.

What kind of email server do you use professionally? How often do you send email directly from your website?

 

 

Author: Kaumil Patel

Kaumil Patel is the Chief Operating Officer of GreenGeeks and has over 13 years of experience in the web hosting industry working for and owning web hosting companies. Kaumil’s expertise is in marketing, business development, operations, acquisitions and mergers.

Updated on March 6, 2017

Was this article helpful?

Related Articles

Comments

Add A Comment