How to Setup Gmail SMTP in WordPress Without Mistakes

How to Setup Gmail SMTP in WordPress Without Mistakes

[lmt-post-modified-info]
11 Mins Read
how-to-setup-gmail-smtp-in-wordpress
Table of content

Email plays a crucial role in managing a WordPress site, from resetting passwords to sending notifications. However, WordPress’s default PHP mail function often leads to issues like emails landing in spam or not being delivered at all. That’s where SMTP (Simple Mail Transfer Protocol) comes in. By connecting your site to Gmail’s SMTP server, you can enhance the reliability and security of your email delivery.

This guide walks you through setting up Gmail SMTP for sending emails in WordPress. You’ll learn how to configure it using the popular WP Mail SMTP plugin or manually, ensuring your emails reach their intended recipients without hassle.

Understanding SMTP and Its Role in WordPress

When WordPress sends emails, such as contact form notifications or password resets, it relies on a built-in function called PHP mail. While this approach is simple, it often lacks the reliability needed for business-critical communication. Emails sent using PHP mail can get flagged as spam or fail to deliver entirely.

This is where SMTP (Simple Mail Transfer Protocol) steps in. SMTP is a standard protocol designed for sending emails reliably over the internet. It ensures that your emails are routed through a proper email server, improving deliverability and reducing the chances of being marked as spam.

Why Default Email Sending Fails

  1. No Authentication: The default method doesn’t authenticate the email server, making messages appear less trustworthy to recipient servers.
  2. Limited Features: It lacks advanced settings like encryption, which can affect email security.
  3. Host Restrictions: Some web hosts restrict the use of PHP mail, causing email failures.

How SMTP Fixes the Issue

SMTP adds an extra layer of reliability by using proper SMTP servers to send emails. It authenticates the sender with login credentials, ensuring secure communication between your WordPress site and the email server. This way, emails are treated as legitimate and are less likely to be flagged as spam.

Why Choose Gmail SMTP?

Using Gmail SMTP for your WordPress emails offers a reliable and secure solution. Gmail’s servers are trusted by most email providers, making it less likely for your emails to be flagged as spam. It’s also an excellent choice if you’re already using a Google account for your business or personal use.

Key Benefits of Gmail SMTP

  1. Enhanced Deliverability
    Gmail’s SMTP server ensures that your emails are routed through trusted servers. This reduces the chances of emails getting blocked or landing in spam.
  2. Security
    Gmail requires authentication through your Google account, ensuring that only authorized users can send emails. With OAuth authentication, your credentials are safe, and you don’t need to store passwords in WordPress.
  3. Easy Integration
    Gmail SMTP integrates seamlessly with WordPress using tools like the WP Mail SMTP plugin. It’s straightforward to configure, even for users with minimal technical knowledge.
  4. Free Option Available
    If you have a free Gmail account, you can send up to 500 emails per day, which is sufficient for most small businesses. For larger needs, a Google Workspace account increases this limit and adds professional features.

Considerations Before Choosing Gmail SMTP

  • Sending Limits: Free Gmail accounts have a daily sending limit of 500 emails, while Google Workspace accounts can send up to 2,000 emails daily. If your site sends a high volume of emails, you might need to consider alternatives.
  • Configuration Complexity: Setting up Gmail SMTP involves multiple steps, such as enabling the Gmail API and creating an app in the Google Cloud Console. However, this guide breaks it down into simple steps.
  • Compatibility: Some plugins or themes may conflict with Gmail SMTP configurations. Testing is essential to ensure everything works smoothly.

Prerequisites for Setting Up Gmail SMTP in WordPress

Before you start configuring Gmail SMTP, make sure you have the following ready. These prerequisites will help you complete the setup smoothly.

What You’ll Need:

  1. Gmail or Google Workspace Account
    Ensure you have an active Gmail account or a professional email account through Google Workspace. Both options work for setting up Gmail SMTP.
  2. Administrator Access to Your WordPress Site
    You’ll need admin-level access to your WordPress site to install plugins and update settings.
  3. WP Mail SMTP Plugin (Optional)
    For an easier setup, you can use the WP Mail SMTP plugin. It simplifies the process and handles the configuration steps.
  4. Google Cloud Console Access
    To enable the Gmail API, you’ll need access to the Google Cloud Console. This is necessary for authenticating your Gmail account with WordPress.
  5. Basic Email Information
    Have your email details ready, such as your email address, password (or app password), and the SMTP server information.
  6. A Backup Solution (Optional)
    While configuring email settings, it’s a good idea to back up your site in case any changes disrupt its functionality.

Once you have everything prepared, you can move on to the configuration steps. We’ll start with using a plugin to streamline the process.

Method 1: Setting Up Gmail SMTP Using a Plugin

Using a plugin is the simplest way to set up Gmail SMTP in WordPress. The WP Mail SMTP plugin is one of the most popular and user-friendly options for this task. Here’s a step-by-step guide to get you started.

Step 1: Install and Activate the WP Mail SMTP Plugin

  1. Log in to Your WordPress Dashboard
    Use your admin credentials to access the backend of your site.
  2. Navigate to Plugins > Add New
    In the left sidebar, hover over “Plugins” and select “Add New.”
  3. Search for WP Mail SMTP
    Use the search bar to find the WP Mail SMTP plugin. Look for the plugin developed by WPForms.
  4. Install and Activate the Plugin
    Click the Install Now button, and once the installation is complete, click Activate to enable the plugin.

Step 2: Configure Plugin Settings

  1. Go to WP Mail SMTP Settings Page
    In your WordPress dashboard, navigate to WP Mail SMTP > Settings.
  2. Enter Email Address and Name
    • Set the From Email to the Gmail address you want to use for sending emails.
    • Add a From Name, which will appear as the sender’s name in outgoing emails.
  3. Mailer Selection
    Scroll down to the Mailer section and select Gmail as your mailer.

Step 3: Set Up a Google App for OAuth Authentication

For security, Gmail uses OAuth 2.0 for authentication. This requires creating a project in the Google Cloud Console and enabling the Gmail API.

  1. Access Google Cloud Console
    Go to the Google Cloud Console and log in with your Google account.
  2. Create a New Project
    • Click on the project dropdown menu at the top of the page and select New Project.
    • Name the project (e.g., “WP Mail SMTP Configuration”) and click Create.
  3. Enable the Gmail API
    • Go to the APIs & Services > Library section in the Cloud Console.
    • Search for the Gmail API and click Enable.
  4. Set Up the OAuth Consent Screen
    • Navigate to APIs & Services > OAuth Consent Screen.
    • Choose External as the user type and click Create.
    • Add a name for your app and save the settings.
  5. Generate OAuth Credentials
    • Go to APIs & Services > Credentials and click Create Credentials > OAuth Client ID.
    • Select Web Application as the application type.
    • Add a redirect URI: arduinohttps://connect.wpmailsmtp.com/google/
    • Copy the Client ID and Client Secret for later use.

Step 4: Integrate WP Mail SMTP with Google App

  1. Enter OAuth Details in Plugin Settings
    • Return to the WP Mail SMTP Settings Page in WordPress.
    • Paste the Client ID and Client Secret into the respective fields.
  2. Authorize the App
    • Click the Allow Plugin to Send Emails button to authorize the plugin to use Gmail for sending emails.
    • You’ll be redirected to Google to log in and approve access.

Step 5: Send a Test Email

  1. Go to WP Mail SMTP Settings
    Navigate to the Email Test tab in the WP Mail SMTP settings.
  2. Enter a Test Email Address
    Add an email address where you’d like to receive the test email.
  3. Send Mail
    Click the Send Email button to test the configuration.
    If successful, you’ll see a confirmation that the email was sent, and it should appear in your inbox.

Common Issues and Troubleshooting

  • Authentication Errors: Ensure the correct Client ID, Client Secret, and Gmail API are enabled.
  • Email Not Delivered: Check your spam folder or confirm the configuration in the settings.
  • Redirect Errors: Double-check the redirect URI entered during the OAuth setup.

Method 2: Setting Up Gmail SMTP Manually Without a Plugin

If you prefer not to use a plugin, you can manually configure Gmail SMTP in WordPress. This method requires editing WordPress files and setting up your Gmail account for SMTP access. Follow these steps carefully.

Step 1: Configure Your Gmail Account

To use Gmail SMTP manually, you must adjust certain settings in your Gmail account to allow external applications to send emails.

  1. Enable Less Secure App Access (For Free Gmail Accounts)Note: For security reasons, Google Workspace accounts may require you to use an App Password instead.
  2. Generate an App Password (For Google Workspace Accounts)
    • Log in to your Google account and navigate to the Security section.
    • Under Signing in to Google, select App Passwords.
    • Choose “Mail” and “Custom” for your application and generate a unique password. Save this password for use in the next steps.

Step 2: Update SMTP Settings in WordPress

To configure WordPress for Gmail SMTP, you’ll need to edit core files and input the SMTP details.

  1. Locate the wp-config.php File
    • Use an FTP client or your hosting provider’s file manager to access your WordPress installation files.
    • Open the wp-config.php file for editing.
  2. Add SMTP Settings
    Add the following code to your wp-config.php file, replacing the placeholders with your Gmail information: phpdefine(‘SMTP_HOST’, ‘smtp.gmail.com’);
    define(‘SMTP_PORT’, 587);
    define(‘SMTP_USER’, ‘your-email@gmail.com’);
    define(‘SMTP_PASS’, ‘your-app-password’); // Use your App Password or Gmail password
    define(‘SMTP_SECURE’, ‘tls’); // Use ssl if port 465 is used
    define(‘SMTP_AUTH’, true);
  3. Modify functions.php
    • Access your theme’s functions.php file through the WordPress admin dashboard or via FTP.
    • Add this code to integrate SMTP settings into WordPress:
    phpadd_action(‘phpmailer_init’, function ($phpmailer) {
        $phpmailer->isSMTP();
        $phpmailer->Host = SMTP_HOST;
        $phpmailer->SMTPAuth = SMTP_AUTH;
        $phpmailer->Port = SMTP_PORT;
        $phpmailer->Username = SMTP_USER;
        $phpmailer->Password = SMTP_PASS;
        $phpmailer->SMTPSecure = SMTP_SECURE;
    });
  4. Save Your Changes
    Save and upload the updated files to your WordPress installation.

Step 3: Test the Configuration

After setting up the SMTP details, test your configuration to ensure emails are being sent correctly.

  1. Install a Testing Plugin (Optional)
    If you prefer, install a lightweight plugin like Check & Log Email to test email functionality.
  2. Send a Test Email
    • Go to Tools > Check Email in your WordPress admin.
    • Enter an email address and click Send Email.
    • Check the inbox of the test email address for the message.
  3. Verify the Results
    If the test email doesn’t arrive, revisit your settings to ensure accuracy.

Common Issues and Troubleshooting

  1. Connection Timeout Errors
    Ensure your web host allows SMTP connections and that the Gmail SMTP server settings are correct.
  2. Authentication Errors
    Verify the email address, password, and SMTP server details.
  3. Email Delivery Issues
    If emails are sent but not received, check spam folders or use an email testing tool to analyze the issue.

Best Practices for Using Gmail SMTP in WordPress

Setting up Gmail SMTP is just the start. To ensure your emails are consistently delivered and comply with Gmail’s guidelines, follow these best practices.

Monitor Email Deliverability

Keep an eye on your email logs to track delivery performance. Plugins like WP Mail SMTP Pro or standalone email logging tools can help you identify delivery failures or issues with the SMTP connection.

  • Tip: Set up a testing schedule to verify that emails are still being sent and received as expected.

Stay Within Gmail’s Sending Limits

Gmail imposes daily sending limits to prevent abuse:

  • Free Gmail Accounts: Up to 500 emails per day.
  • Google Workspace Accounts: Up to 2,000 emails per day.

If your WordPress site exceeds these limits (e.g., large eCommerce sites or email marketing campaigns), consider alternatives like Amazon SES, SendGrid, or Mailgun for high-volume email sending.

Use Professional Email Addresses

Using a professional email address tied to your domain (e.g., you@yourbusiness.com) improves your credibility and reduces the likelihood of emails being marked as spam. If you’re on Google Workspace, you can use your Google Workspace email address for this purpose.

Implement Email Authentication

To improve email reliability and prevent spoofing, configure these authentication protocols:

  • SPF (Sender Policy Framework): Verifies that Gmail is authorized to send emails on behalf of your domain.
  • DKIM (DomainKeys Identified Mail): Ensures email integrity during transit.
  • DMARC (Domain-based Message Authentication, Reporting, and Conformance): Provides instructions for handling authentication failures.

Most domain registrars and hosting providers offer tools to configure these settings.

Use Secure Connections

Always use TLS (port 587) or SSL (port 465) for secure email transmissions. These protocols encrypt your emails, protecting sensitive data.

Regularly Test Your Setup

Periodically send a test email to ensure the Gmail SMTP configuration is still functional. Updates to WordPress, plugins, or Gmail itself can occasionally disrupt the connection.

Consider a Backup SMTP Option

Sometimes Gmail’s servers might face temporary issues or rate-limiting. Setting up a fallback SMTP provider can ensure uninterrupted email delivery for your WordPress site.

Troubleshooting Common Issues

Even with a proper setup, you might encounter issues with Gmail SMTP in WordPress. Here are some common problems and how to resolve them.

1. Authentication Errors

Symptom:
You see errors like “Could not authenticate” or “SMTP Error: Could not connect to SMTP host.”

Causes:

  • Incorrect Client ID or Client Secret in the plugin or settings.
  • Gmail’s API isn’t enabled in the Google Cloud Console.
  • Google account doesn’t allow less secure apps or requires additional permissions.

Solutions:

  • Double-check the Client ID and Client Secret in the WP Mail SMTP plugin or manual configuration.
  • Verify that the Gmail API is enabled in your Google Cloud Console.
  • If using a Google Workspace account, ensure App Passwords are set up correctly.

2. Emails Not Delivered

Symptom:
Emails appear to be sent successfully but never arrive in the recipient’s inbox.

Causes:

  • Emails are flagged as spam by the recipient’s email provider.
  • SPF, DKIM, or DMARC records aren’t set up for your domain.
  • The recipient’s email server rejects emails from generic Gmail addresses.

Solutions:

  • Check the recipient’s spam or junk folder.
  • Configure SPF, DKIM, and DMARC records in your domain registrar’s DNS settings.
  • Use a professional email address tied to your domain instead of a generic Gmail address.

3. Gmail Sending Limit Reached

Symptom:
Emails stop sending because the daily sending limit is exceeded.

Causes:

  • Free Gmail accounts are limited to 500 emails/day.
  • Google Workspace accounts are limited to 2,000 emails/day.

Solutions:

  • Monitor email volume to stay within limits.
  • If you frequently exceed the limits, switch to a dedicated SMTP service like SendGrid or Mailgun for bulk emails.

4. Connection Timeout Errors

Symptom:
You see errors like “SMTP server timed out” or “Could not connect to SMTP host.”

Causes:

  • Web host blocks outgoing SMTP connections.
  • Incorrect SMTP host, port, or encryption settings.

Solutions:

  • Verify that your web host allows outgoing SMTP connections. Contact your host’s support team if necessary.
  • Double-check the SMTP host (smtp.gmail.com), port (587 or 465), and encryption settings (TLS or SSL).

5. Redirect Errors During OAuth Authentication

Symptom:
The plugin fails to redirect you to Gmail for authentication.

Causes:

  • Incorrect redirect URI in the Google Cloud Console.
  • Plugin or theme conflicts with the WP Mail SMTP plugin.

Solutions:

  • Ensure the redirect URI is set to: arduinohttps://connect.wpmailsmtp.com/google/
  • Temporarily deactivate other plugins and switch to a default WordPress theme to identify conflicts.

6. Debugging Gmail API Errors

Symptom:
You encounter API-related errors when enabling the Gmail API.

Causes:

  • API quota exceeded for your Google Cloud project.
  • Missing OAuth consent screen configuration.

Solutions:

  • Check API quotas in the Google Cloud Console and upgrade if necessary.
  • Ensure all required fields (e.g., app name, support email) are completed in the OAuth consent screen.

 FAQs

1. What are Gmail’s daily sending limits for SMTP?

Free Gmail accounts: Up to 500 emails/day.
Google Workspace accounts: Up to 2,000 emails/da

2. Can I use a free Gmail account for this setup?

Yes, a free Gmail account can be used to configure SMTP. However, it’s limited to 500 emails per day, which might not be enough for larger websites.

3. What do I need to set up Gmail SMTP in WordPress?

A Gmail or Google Workspace account.
Admin access to your WordPress site.
The WP Mail SMTP plugin or manual configuration using SMTP settings.
Access to the Google Cloud Console to enable the Gmail API (if using OAuth).

4. How do I fix “Could not authenticate” errors?

Verify the Client ID and Client Secret entered in your WP Mail SMTP plugin.
Ensure the Gmail API is enabled in the Google Cloud Console.
For free Gmail accounts, enable Less Secure App Access or use an App Password.

Conclusion

Setting up Gmail SMTP in WordPress ensures that your site’s emails are delivered reliably and securely. By using Gmail’s trusted SMTP servers, you reduce the chances of your messages ending up in spam folders or failing to send altogether.

This guide covered both plugin-based and manual methods for configuring Gmail SMTP, allowing you to choose the approach that works best for your needs. Whether you’re a small business owner sending email notifications or a marketer using forms to capture leads, Gmail SMTP offers a professional and dependable solution.

Here’s a quick recap:

  • Why SMTP Matters: It improves email deliverability compared to PHP’s mail function.
  • Why Gmail SMTP: Secure, reliable, and easy to set up with tools like the WP Mail SMTP plugin.
  • Best Practices: Monitor deliverability, stay within Gmail’s sending limits, and use professional email addresses.

With the steps and tips outlined here, your WordPress site is now equipped to handle email tasks efficiently. Troubleshooting tips ensure that you can address any hiccups along the way.

Scale Cold Outreach Using AI

Build hyper personalized outreach in just few clicks at Scale