Setting Up WordPress Gmail SMTP for Reliable Email Delivery
Are you struggling with emails from your WordPress site ending up in spam folders or not being delivered at all? If you're sending important transactional emails, like password resets or order confirmations, you need a dependable solution. That's where Gmail SMTP comes in. We'll guide you through setting up WordPress Gmail SMTP to improve email deliverability.
Why Use Gmail SMTP with WordPress?
Avoid Spam Filters: Default WordPress emails often land in spam because the wp_mail()
function lacks proper header authentication. Major email providers and web hosts may block these emails, leading to poor deliverability.
Security and Reliability: SMTP (Simple Mail Transfer Protocol) provides enhanced security compared to the PHP mail function. Gmail's SMTP server is especially useful for small businesses and websites with moderate traffic due to its reliable and secure nature.
Free Gmail SMTP vs. Google Workspace SMTP
- Free Gmail SMTP: Suitable for small-scale use, but limited to 500 emails per day and lacks custom domain email addresses.
- Google Workspace SMTP: Offers a custom domain (e.g., [email protected]), domain verification with SPF, DKIM, and DMARC records, and a daily limit of 10,000 emails. This is a paid service but improves sender reputation significantly.
Prerequisites
Before we start, ensure you have either a Google Workspace account or a Gmail account.
Installing the WP Mail SMTP Plugin
- Go to your WordPress dashboard and click 'Plugins' on the left panel.
- Click 'Add New' and search for 'WP Mail SMTP'.
- Install and activate the 'WP Mail SMTP by WPForms' plugin.
Configuring WP Mail SMTP Settings
- Find 'WP Mail SMTP' in your WordPress dashboard and click 'Settings'.
- Under 'From Email' and 'From Name', input the email and name you want to appear on your outgoing emails.
Note: If 'From Email' is unavailable, ensure you enable Google Mailer using your Client ID.
Integration Using Gmail's SMTP Credentials
After configuring 'From Email' and 'From Name', select 'Other SMTP' instead of 'Google/Gmail'.
Input the following details:
- SMTP Host: smtp.gmail.com
- Encryption: Choose SSL or TLS for security.
- SMTP Port: Use 465 for SSL or 587 for TLS.
- Authentication: Turn this on.
- SMTP Username: Your Gmail or Google Workspace email.
- SMTP Password: Your Google account app password.
- Save your settings.
You're now ready to use WP Mail SMTP with Gmail as your email sender!
Tip: WP Mail SMTP also works seamlessly with WooCommerce and Contact Form 7. Remember to test sending an email to ensure everything is set up correctly.
Keep in mind, for sending high volumes of emails or if you require professional features, third-party services like Mailgun or SendGrid may be more suitable.
How to Integrate Gmail API for Sending Emails with WP Mail SMTP
If you're looking for a more secure way to send emails from your WordPress site, integrating Gmail API is the solution. Follow these steps to set up Gmail API with the WP Mail SMTP plugin:
Creating a Project in Google Cloud Console
- While in your WordPress dashboard, choose
Google/Gmail
as your mailer in WP Mail SMTP Settings. - Visit Google Cloud Console and sign in with your Google account.
- Click on the
New project
button at the top right. - Enter a project name and location, then click
Create
.
Enabling Gmail API
- Go to the
APIs & Services
>Library
. - In the search box, type “Gmail API” and select it.
- Click the
Enable
button.
Generating API Credentials
- Click on
Create Credentials
. - Make sure “Gmail API” is selected and choose “User data” for the question about data accessing.
- Click
Next
.
Configuring OAuth Consent Screen
- Fill in details like your app name, support email, and developer contact.
- Optionally upload an app logo if desired.
- Click
Save and continue
.
Creating OAuth Client ID
- Skip the
Scopes
configuration by clickingSave and continue
. - For the application type, select
Web application
. - Enter a name for your OAuth 2.0 client ID.
- In the
Authorized redirect URIs
field, add this URL:https://connect.wpmailsmtp.com/google/
(skip the Authorized JavaScript origins field). - Click
Create
.
Publishing Your Google App
For Gmail (not Google Workspace):
- Navigate to the
OAuth Consent Screen
tab. - Click
Publish App
and confirm by clickingConfirm
.
Connecting Gmail API with WP Mail SMTP
- In Google Cloud Console, go to
Credentials
. - Next to your OAuth client, click the pencil icon to edit.
- Copy the
Client ID
andClient Secret
.
Configuring WP Mail SMTP Plugin
- Return to your WordPress dashboard and open WP Mail SMTP plugin settings.
- Paste the copied
Client ID
andClient Secret
in the respective fields. - Click
Save Settings
. - Follow the prompt to
Allow plugin to send emails using your Google account
.
Finalizing the Setup
- Log in to your Google account when prompted.
- If using Gmail, click
Advanced
and proceed to wpmailsmtp.com, then continue. - For Google Workspace users, directly press
Continue
to grant permissions.
Your WordPress website is now connected to Gmail SMTP using the Gmail API for secure email sending.
Security Tip: Always keep your Client ID and Client Secret confidential to protect your Google account.