Are you having trouble sending emails from your WordPress site? One easy way to solve this is by sending WordPress emails using the Gmail SMTP server. In this article, we will show you how to send emails from your WordPress site using the Gmail SMTP server.
Why and When You Need Gmail SMTP Server for WordPress Emails
By default, WordPress uses the PHP mail function to send out email notifications. However, this function does not work as expected due to a number of reasons.
Most WordPress hosting companies restrict usage of this function to prevent abuse and spam.
Spam filters on popular email service providers check incoming emails to monitor if they are sent from authentic mail servers. Default WordPress emails fail this check and sometimes may not even make it to the spam folder.
SMTP (Simple Mail Transfer Protocol) is the industry standard for sending emails. Unlike PHP mail function, SMTP uses proper authentication which increases email deliverability.
Gmail provides SMTP service that you can use to send out emails from your WordPress site. If you just want to send WordPress notification emails to yourself and few users on your site, then Gmail SMTP servers are the best option.
However, if you are planning on sending newsletter emails using WordPress, then you should use a mass emailing service provider, like MailGun or SendGrid.
Free vs Paid Gmail SMTP Service for WordPress
You can use your free Gmail account to send out WordPress emails. However, for better deliverability, we recommend using paid Google Apps for Work with Gmail.
With Google Apps for Work, you get your own professional branded email address such as (email@example.com).
Google Apps require you to add MX records to your domain name which means that your emails will appear to be coming from your own domain name boosting authenticity and ensuring better deliverability.
We use Google Apps for Work for WPBeginner and can honestly say it’s the best.
How to Send WordPress Emails Using Gmail SMTP Server
If you decided to use Google Apps for Work, then you first need to set up your domain to work with Google Apps. We have a step by step tutorial on how to setup a professional email address with Google Apps and Gmail.
Rest of the instructions are the same whether you are using paid or free Gmail account.
Upon activation, you need to visit Settings » WP Mail SMTP page to configure the plugin settings.
First you need to make sure that you use your Gmail email address in the ‘From Email’ field. Next, you need to provide the sender name.
WP Mail SMTP plugin offers two ways to connect your WordPress site to the Gmail servers.
The first method uses OAuth Authentication. This is a more secure method to send emails using Gmail servers.
The second method is by entering Gmail SMTP settings manually. This method is not recommended because it is less secure.
That being said, let’s set up WordPress to use Gmail SMTP for sending emails.
Method 1: Setting up Gmail to Send WordPress Emails using OAuth Protocol
This method is recommended for all users. It is more secure and once you set it up, you’ll never have to do that again.
You need to start by selecting Gmail as your mailer and set the return path to be the same as sender.
Next, you will see the option to enter your Client ID, Client Secret, and a URL in ‘Authorized redirect URI’ field.
Let’s set up these fields.
Creating an App and Generate API Keys for Gmail
Visit the Google Developers Console website and create a new project.
If you don’t see the blue button to create a project, then you can also click on select a project drop down and create a new project.
You’ll be asked to provide a name for your project. Give it a memorable name, so that you can easily recognize it in the future.
After that, click on the create button to continue.
Developer console will now create your project and take you to its dashboard. Google offer developers access to many of their APIs and services. You need to enable the APIs that you will be needing for this project.
Click on Enable APIs and services button to continue.
This will bring you to the APIs library page. Next, you need to type Gmail in the search box to quickly find the Gmail API and click to select it.
You will now see an overview of the API and what it can do. Simply click on the ‘Enable’ button to continue.
Now that your API is enabled, the next step is to create credentials that you can use in your WP Mail SMTP plugin settings.
Click on the create credentials button to continue.
To continue, click on the ‘What credentials do I need?’ button.
You will now be asked to provide a name for your OAuth client name. You can enter ‘WP Mail SMTP’ here.
After that click on the ‘Create client ID’ button to continue.
Next, you need to enter a name for OAuth consent screen. You can put the plugin’s name here.
After entering the details, click on the continue button and the developer console will show your client ID. You can copy and paste this in the WP Mail SMTP plugin’s settings page. However, you will still need to add your client secret key.
Go ahead and click on the Done button to move on.
You will now be taken to your project’s credentials page. You will see your recently created credentials listed there. You need to click on the edit icon next to your credentials to continue.
This will bring you to the edit credentials page where you will be able to see your client secret key. You need to copy and paste the key in your plugin’s settings page.
Return back to plugin’s settings page in your WordPress admin area. Now that you have both client ID and client secret keys, you need to click on the save settings button to continue.
The plugin will now store your settings and reload the page. After that you need to scroll down to the bottom of the settings page and click on the ‘Allow plugin to send emails using your Google account’ button.
This will take you to your account on Google, and you will be asked to give the website permission to send emails on your behalf.
Click on Allow button to give permissions.
After that, you will be redirected back to your website where you will see a success message.
Method 2: Setting up Gmail SMTP as SMTP Sender
This method allows you to manually connect to Gmail’s SMTP servers to send your WordPress emails.
First, you need to visit Settings » WP Mail SMTP page to configure the plugin settings.
You need to start by providing the Gmail address you want to use in the From email field, and your name in the name field.
Next, you need to select ‘Other SMTP’ as your mailer and check the box next to return path.
After that, scroll down to the Other SMTP section to configure more settings.
Here is the exact configuration you need to add in the plugin settings:
- SMTP Host: smtp.gmail.com
- SMTP Port: 465
- Encryption: Use SSL encryption
- Authentication: Turn on authentication
- Username: Your complete Gmail address, e.g. firstname.lastname@example.org or email@example.com
- Password: Password of your Gmail account
Once you are done, click on the save changes button to store your settings.
That’s all, you have successfully setup WP Mail SMTP to use Gmail SMTP servers.
Testing Your WP Mail SMTP Settings
WP Mail SMTP plugin allows you to test your email settings, so you can make sure that everything is working properly.
You need to visit Settings » WP Mail SMTP page and click on the ‘Email Test’ tab. Simply provide an email address that you can access in the send to field and click on the send email button.
You will see a success message. You can now check your inbox to see a message with the subject line ‘WP Mail SMTP: Test Email to…’.
That’s all, you have successfully setup your WordPress site to send emails using Gmail SMTP servers.
Troubleshooting Gmail SMTP Not Working Issues
We have seen users encounter few issues when using Gmail SMTP with certain shared hosting configurations.
Take the following steps to fix the Gmail SMTP issue:
- Login to your cPanel account and create an email account that matches your Google apps email address. This might seem strange because you’re not using your server for emails. This step basically tricks your server into believing that you’re sending the email through the server.
- In your cPanel account, go to the MX Records and change the MX routing from automatic to remote. It might be a little tricky to find since each host now has custom cPanel interface. You need to look for a small link next to MX that says Email Routing: Remote Mail Exchanger.
- After that log back into your WordPress site and send a test email.
We hope this article helped you learn how to send email in WordPress using the Gmail SMTP server. You may also want to see our list of the 5 best contact form plugins for WordPress.
The post How to Send Email in WordPress using the Gmail SMTP Server appeared first on WPBeginner.
Vía WPBeginner http://ift.tt/1b7nbf2