Gmail SMTP Plugin for WordPress

Gmail SMTP is an advanced SMTP mailing plugin for WordPress for sending an email via Gmail SMTP server. Unlike most SMTP plugins It uses the OAuth 2.0 protocol to authorize access to the Gmail API instead of password authentication.

gmail smtp wordpress plugin

Gmail SMTP Benefits

1. Gmail SMTP plugin does not store your password. It uses the OAuth 2.0 mechanism for SMTP authentication. It means a more secure login system for users.

2. Gmail SMTP plugin uses PHPMailer – a very popular PHP library used in the core WordPress for sending an email. This is to make sure that users can still get full benefits of the default email functionality.

3. Gmail SMTP plugin takes a big headache away from you because you no longer need to Allow Less Secure Apps on your Gmail account. This is an option that users had to enable in order to fix SMTP connection issue. This issue went viral from December 2014, when Google started imposing OAuth 2.0 authentication to access their apps. This option affects SMTP mailing because applications that perform password authentication to IMAP, POP, or SMTP are considered Less Secure Apps.

As far as I know, this issue still affects almost all the SMTP plugins out there.

How OAuth 2.0 Authorization Works

1. You register a web application in the Google Developers Console.

2. When this application is launched it requests that you give it access to data in your Google account.

3. If you consent, the application receives credentials to access the API.

Installation

You can install the Gmail SMTP plugin in one of the following ways:

Option 1 (Quick & Easy install)

  1. Go to Plugins->Add New from your WordPress admin dashboard
  2. Search for “gmail smtp naa986”
  3. Click Install once you have found it

Option 2 (Manual install)

  1. Download the zip version of the plugin
  2. Go to Plugins->Add New
  3. Click Upload Plugin
  4. Select the zip file on your computer
  5. Install it

Gmail SMTP Configuration

In order to get started with the plugin go to Settings->Gmail SMTP from your admin dashboard.

screenshot of gmail smtp plugin menu

Gmail SMTP Project Creation

1. Go to console.cloud.google.com/apis/dashboard.

2. Login to your Google account which will be used to send an email.

3. Create a new project where your application will be registered.

screenshot showing how to create a new project in the Google Developers Console

It doesn’t have to be “Gmail SMTP Project 1”. You can name it whatever you like. I chose a meaningful name because I have multiple projects in it.

Credentials/App Creation

1. Once the project is created go to Credentials > CREATE CREDENTIALS and select OAuth client ID.

2. In order to create an OAuth client ID, you need to configure the OAuth consent screen first. So click CONFIGURE CONSENT SCREEN.

screenshot showing how to configure the consent screen when creating an OAuth Client ID

3. Choose how you want to configure and register your app. Since I’m not using G Suite I had to choose External.

screenshot showing how to choose a user type in the oauth consent screen of the google developers console

4. Enter a name (e.g. Gmail SMTP) for the OAuth consent screen.

screenshot showing the OAuth consent screen 2 in the google developers console

5. You can configure optional fields such as Authorized domains, Application home page, Application privacy policy link and Application terms of service link (I was able to skip all and click SAVE AND CONTINUE). You do however need to enter an email address under the Developer contact information section.

screenshot showing part 2 of the consent screen 2 in the google developers console

6. Skip the Scopes screen.

screenshot showing the Scopes tab in the OAuth consent screen of the Google cloud console

7. Add a test user if you plan to use this app in test mode (This is not required if you want to publish it).

screenshot showing the Test users tab in the OAuth consent screen of the Google cloud console

8. Keep your app in test mode or publish it. If the Publishing status is set to In production, a warning message (This app isn’t verified) may appear on the consent screen that you can easily skip.

screenshot showing the Summary tab in the OAuth consent screen of the Google cloud console

Now that the OAuth consent screen has been configured you can create an OAuth Client ID.

9. Go to the Credentials tab and select OAuth client ID under CREATE CREDENTIALS.

screenshot showing how to select OAuth client Id under CREATE CREDENTIALS in the google developers console

10. Set the application type to Web application and enter a name for it (e.g. Gmail SMTP App). Copy the Authorized Redirect URL from the settings and paste it into the field here.

screenshot showing how to create a client id by creating a new web app in the google developers console

11. Click Create. This will generate a Client ID and Client Secret for you. Copy and paste them into the settings area of the plugin.

Gmail SMTP Settings Configuration

1. Configure the rest of the settings. It includes,

OAuth Email Address: The email address that you will use for SMTP authentication. This should be the same email used in the Google Developers Console.

From Email Address: The email address which will be used as the From Address when sending an email.

From Name: The name which will be used as the From Name when sending an email.

Type of Encryption: The encryption which will be used when sending an email (either TLS/SSL). By default, it should be set to TLS since SSL has been deprecated since 1998.

SMTP Port: The port which will be used when sending an email. If you choose TLS it should be set to 587. For SSL use port 465 instead.

2. Click Save Changes.

Now that you have configured the settings a Grant Permission button will appear.

screenshot showing how to grant permission from the gmail smtp settings

3. Clicking on it will take you to a consent screen where you will be able to grant this app access to the Gmail API.

allow application screen of google developers console

4. When you click Allow you will get redirected back to the plugin settings. You should see a message like Access Granted Successfully. The SMTP Status should also get set from Not Connected to Connected.

screenshot of gmail smtp settings

That’s it. Gmail SMTP plugin will now be able to take control of all outgoing email from your website.

Test Email

In order to test the email functionality, you can send a test email from the Test Email tab.

Debug option is enabled by default for the test email functionality – which means you would be able to see if the plugin was able to send the email without any error.

screenshot showing how to send a test email from the gmail smtp plugin settings

Troubleshooting

By default, your SMTP port should be configured on 587 (with TLS encryption). If you can’t get it to work then you can try changing it to 465 (with SSL encryption).

If you still can’t get either to work try port 25 with TLS first and then SSL. Please note that most servers don’t support encryption on port 25, which is why port 587 and 465 are the preferred options.

Fresh Authorization / Removing Access From the Application

For some reason, if you ever want to stop using this plugin or do a fresh authorization this option might come in handy.

Revoke Access menu allows you to remove access from a previously authorized application.

screenshot showing the revoke access settings of gmail smtp plugin

First, you need to click on the account settings link. This will take you to a page where you can remove access from the Gmail SMTP application.

screenshot showing how to remove access from an application in the google developers console

Once you have removed access from it, go back to the Remove Access tab in the plugin settings and delete the Access key.

Access key is a token that the plugin received when you first granted your app access to the Gmail API. This token is necessary to communicate with the Gmail API and send an email. In order to avoid any confusion, the plugin does not show it on the settings page.

Once you delete this token the plugin can no longer connect to the Gmail SMTP server or send an email. This means you will need to reauthorize (using the web application link in the settings) before you can start using the plugin again. However, you won’t need to set up everything from scratch as long as the project still exists in your Google Developers Console.

Gmail SMTP Add-ons

Gmail SMTP plugin comes with add-ons that you can use to enhance its functionality on your website.

Reply-To

Reply-To add-on lets you set a reply-to address for all outgoing email messages.

Cc

Cc add-on lets you set a cc recipient for all outgoing email messages.

712 thoughts on “Gmail SMTP Plugin for WordPress”

  1. Hi…. I changed the server and now Gmail SMTP isn’t working. Is it a problem with my new server’s configuration?

    Error:

    Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
    Connection: opened
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “220 smtp.gmail.com ESMTP f72sm6140677qke.25 – gsmtp”
    SERVER -> CLIENT: 220 smtp.gmail.com ESMTP f72sm6140677qke.25 – gsmtp
    CLIENT -> SERVER: EHLO ~^(www\.)?(?.+)$
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “501-5.5.4 HELO/EHLO argument “~^(www\.)?(?.+)$” invalid, closing”
    SMTP -> get_lines(): $data is “501-5.5.4 HELO/EHLO argument “~^(www\.)?(?.+)$” invalid, closing”
    SMTP -> get_lines(): $str is “501-5.5.4 connection.”
    SMTP -> get_lines(): $data is “501-5.5.4 HELO/EHLO argument “~^(www\.)?(?.+)$” invalid, closing501-5.5.4 connection.”
    SMTP -> get_lines(): $str is “501 5.5.4 https://support.google.com/mail/?p=helo f72sm6140677qke.25 – gsmtp”
    SERVER -> CLIENT: 501-5.5.4 HELO/EHLO argument “~^(www\.)?(?.+)$” invalid, closing501-5.5.4 connection.501 5.5.4 https://support.google.com/mail/?p=helo f72sm6140677qke.25 – gsmtp
    SMTP ERROR: EHLO command failed: 501-5.5.4 HELO/EHLO argument “~^(www\.)?(?.+)$” invalid, closing501-5.5.4 connection.501 5.5.4 https://support.google.com/mail/?p=helo f72sm6140677qke.25 – gsmtp
    CLIENT -> SERVER: HELO ~^(www\.)?(?.+)$
    SERVER -> CLIENT:
    SMTP ERROR: HELO command failed:
    SMTP NOTICE: EOF caught while checking if connected
    Connection: closed
    SMTP Error: Could not connect to SMTP host.
    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

    Reply
    • @Marco, Have you done a fresh setup after changing the server?

      Reply
      • A friend of mine did it for me. He installed nginx, Php7, etc.
        Basicly is the same estructure of the old server. I’m suspicious that it’s something misconfigured (related to smtp connect).
        How can I check if smtp connect, PHPMailer, etc. are fine?

        Reply
        • @Marco, Do you have all the info saved in the settings? If so please follow the instructions in the “Fresh Authorization / Removing Access From the Application” section.

          Reply
          • Hi… I did it. But it still doesn’t working.
            The same error is happening.

          • Hi… any idea of what I can do to solve the problem?

  2. hi,
    the below error message i receive on Test Email tab:
    Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ()
    Connection: Failed to connect to server. Error number 2. “Error notice: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (No connection could be made because the target machine actively refused it.)
    SMTP ERROR: Failed to connect to server: No connection could be made because the target machine actively refused it. (10061)
    SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
    please help.

    Reply
  3. Hi!

    I followed the instructions and thought it worked. Until I tried to send an email. I get a “405 Not Allowed” message. I’ve passed the grant access successfully and thought I had it working.
    What causes this error?

    I had to become a member of the Google group Allow Risky Access Permissions By Unreviewed Apps to get the grant access. The site is registered in the Search Console.

    Thank you!

    Reply
  4. I am getting below error, I am on digital ocean, tried below methods:
    – Disable IPv6
    – Increasing time outs – fastcgi_read_timeout 120;

    upstream timed out (110: Connection timed out) while reading response header from upstream, client: 167.220.238.130, server: mxc-test.couponwish.in, request: “POST /wp-admin/options-general.php?page=gmail-smtp-settings&action=test-email HTTP/1.1”,

    upstream: “fastcgi://unix:/run/php/php7.0-fpm.sock”, host: “”, referrer: “http:///wp-admin/options-general.php?page=gmail-smtp-settings&action=test-email”

    Reply
  5. Hi, can this plugin use a different e-mail to send the mail?, i need to send from no-reply-domain@gmail.com but i want the developer console under admin-domain@gmail.com

    Reply
    • @Leonardo, Gmail doesn’t let you change the from email address for security reasons. The plugin does pass it to their API but they simply ignore it at the moment.

      Reply
      • Got it, hope that can be possible on the future. Thank you.

        Reply
  6. Still struggling with adding info@mydomain.com. Info@ is actually a Distribution Group alias hence no actual login username and password. Any other ways to change FROM email to info@mydomain.com? Thanks.

    Reply
    • @Prageeth, Can you please explain what you are trying to do? You can specify any from email address as you want in the settings. But the OAuth setup needs to be done with a Gmail account (which will send the actual email).

      Reply
      • Hi, thanks for the quick reply. I setup Gmail SMTP v1.1.2 using a Gmail email for OAuth Email Address. All went well.
        However, I want our info@mydomain.com to be the ‘From Email Address’ and not the Gmail email. Firstly I changed ‘From Email Address’ to info@mydomain.com. Then I went in to account ‘Settings’ in Gmail > Accounts and import> Send mail as > here, I tried to add info@ourdomain.com but it prompts me to provide SMTP server, username and password. Username and password do not exist as the email address I want (info@mydomain.com) to use as ‘From Email Address’ is a Distribution Group email in Exchange Server.

        How do I make info@mydomain.com as ‘From Email Address’?

        Reply
        • @Prageeth, For security reasons Gmail doesn’t allow you to change the from email address at the moment. The plugin does pass it to their API but It automatically overrides the from address with your OAuth email address.

          Reply
          • Ok. Thanks very much for clarifying.

  7. Hi there, the plugin was working fine until a few days ago and then now i keep getting the following errors. Your URGENT response would be appreciated:

    Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
    Connection: opened
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “220-melfi.bbsnoc.com ESMTP Exim 4.89 #1 Mon, 26 Jun 2017 18:10:54 +1000 ”
    SMTP -> get_lines(): $data is “220-melfi.bbsnoc.com ESMTP Exim 4.89 #1 Mon, 26 Jun 2017 18:10:54 +1000 ”
    SMTP -> get_lines(): $str is “220-We do not authorize the use of this system to transport unsolicited, ”
    SMTP -> get_lines(): $data is “220-melfi.bbsnoc.com ESMTP Exim 4.89 #1 Mon, 26 Jun 2017 18:10:54 +1000 220-We do not authorize the use of this system to transport unsolicited, ”
    SMTP -> get_lines(): $str is “220 and/or bulk e-mail.”
    SERVER -> CLIENT: 220-melfi.bbsnoc.com ESMTP Exim 4.89 #1 Mon, 26 Jun 2017 18:10:54 +1000 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
    CLIENT -> SERVER: EHLO cym.org
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “250-melfi.bbsnoc.com Hello cym.org [209.141.49.197]”
    SMTP -> get_lines(): $data is “250-melfi.bbsnoc.com Hello cym.org [209.141.49.197]”
    SMTP -> get_lines(): $str is “250-SIZE 52428800”
    SMTP -> get_lines(): $data is “250-melfi.bbsnoc.com Hello cym.org [209.141.49.197]250-SIZE 52428800”
    SMTP -> get_lines(): $str is “250-8BITMIME”
    SMTP -> get_lines(): $data is “250-melfi.bbsnoc.com Hello cym.org [209.141.49.197]250-SIZE 52428800250-8BITMIME”
    SMTP -> get_lines(): $str is “250-PIPELINING”
    SMTP -> get_lines(): $data is “250-melfi.bbsnoc.com Hello cym.org [209.141.49.197]250-SIZE 52428800250-8BITMIME250-PIPELINING”
    SMTP -> get_lines(): $str is “250-AUTH PLAIN LOGIN”
    SMTP -> get_lines(): $data is “250-melfi.bbsnoc.com Hello cym.org [209.141.49.197]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN”
    SMTP -> get_lines(): $str is “250-STARTTLS”
    SMTP -> get_lines(): $data is “250-melfi.bbsnoc.com Hello cym.org [209.141.49.197]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS”
    SMTP -> get_lines(): $str is “250 HELP”
    SERVER -> CLIENT: 250-melfi.bbsnoc.com Hello cym.org [209.141.49.197]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
    CLIENT -> SERVER: STARTTLS
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “220 TLS go ahead”
    SERVER -> CLIENT: 220 TLS go ahead
    SMTP Error: Could not connect to SMTP host.
    CLIENT -> SERVER: QUIT
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “221 melfi.bbsnoc.com closing connection”
    SERVER -> CLIENT: 221 melfi.bbsnoc.com closing connection
    Connection: closed
    SMTP connect() failed. github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

    Reply
  8. Hello I am using your plugin but when I try to send a test message it returns a 405 error after a while. I am using also contact form 7 and when I submit the form it returns the same 405 error after a while trying to load. I saw another comment on this but no answer, could you please help?

    Thanks,

    Reply
    • @Juan, Do you see any debug data when you send a test email? Please copy and paste the content from your “Server Info” tab so I can take a look.

      Reply
      • @Admin, thanks for the reply, This is all I am getting: 405 Not Allowed
        nginx/1.12.0
        I am not sure where to find debug data, so if you could please guide I would appreciate it.
        Best regards, Juan

        Reply
        • Here is the server info:

          OS: Linux box1273.bluehost.com 3.12.74-20170619.148.ELK6.x86_64 #1 SMP Mon Jun 19 19:48:05 CDT 2017 x86_64
          PHP version: 5.6.29
          WordPress version: 4.8
          WordPress multisite: No
          openssl: Available
          allow_url_fopen: Enabled
          stream_socket_client: Available
          fsockopen: Available
          cURL: Available
          cURL Version: 7.24.0, OpenSSL/1.0.0

          Reply
          • @Juan, Thanks. The debug data shows when an email is sent from the “Test Email” tab. Is this all you see “405 Not Allowed nginx/1.12.0”?

            Please check with your web host to see if they allow connection to “smtp.gmail.com”. Your web server might be configured to only allow their own SMTP host.

  9. When attempting top send a test email, the (very small) notice appears:

    Invalid address: (punyEncode) Cara Hotels

    Return and from address are both resources@carahotels.com which is a valid email box on our GSuite account.

    Server info
    OS: Linux rm-2003-23.datarealm.com 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24 UTC 2017 x86_64
    PHP version: 5.6.30
    WordPress version: 4.8
    WordPress multisite: No
    openssl: Available
    allow_url_fopen: Enabled
    stream_socket_client: Available
    fsockopen: Available
    cURL: Available
    cURL Version: 7.29.0, NSS/3.21 Basic ECC

    Reply
  10. I was using this plugin previously without issue, however I had needed to uninstall the app. After uninstalling I revoked access and deleted the key. I’ve reinstalled the plugin and found that previous information has populated the plugin, and I cannot get the Grant Permission button to appear again.

    Is there a way for me to clear the information previously used and set the plugin to the new Project I’m trying to link this plugin to?

    Reply
    • @Derek, Have you updated the client ID and Secret in the settings? Once you delete the access key in the settings the grant permission button should appear again.

      Reply
      • I actually created a new project as I’d deleted the previous one, and then updated the Key and Secret, yet the button isn’t showing.

        Reply
        • @Derek, And you have also deleted the access key in the “Revoke Access” tab?

          Reply
          • Hah! Love it when I miss the obvious button. Thanks for pointing that out. Looks like the plugin doesn’t accept Google Groups setup with the email address. I was able to get it to work with my primary email address. Thanks for the help.

  11. Some solution for this error:

    Fatal error: Uncaught exception ‘Google_Auth_Exception’ with message ‘Error refreshing the OAuth2 token, message: ‘{ “error” : “invalid_request”, “error_description” : “Missing required parameter: refresh_token” }” in /var/www/html/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Auth/OAuth2.php:363 Stack trace: #0 /var/www/html/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Auth/OAuth2.php(278): Google_Auth_OAuth2->refreshTokenRequest(Array) #1 /var/www/html/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Client.php(457): Google_Auth_OAuth2->refreshToken(NULL) #2 /var/www/html/wp-content/plugins/gmail-smtp/class.phpmaileroauthgoogle.php(142): Google_Client->refreshToken(NULL) #3 /var/www/html/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php(471): GmailXOAuth2->getOauth64() #4 /var/www/html/wp-content/plugins/gmail-smtp/class.phpmaileroauth.php(153): SMTP->authenticate(”, ”, ‘XOAUTH2’, ”, ”, Object(GmailXOAuth2)) #5 /var/www/html/wp-content/plugins/gmail-smtp/PHP in /var/www/html/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Auth/OAuth2.php on line 363

    Reply
    • @pol, Please check the troubleshooting section for details.

      Reply
  12. Great plugin. I was using it without problems until recently. I had to change the password on my email account and emails stopped sending out.
    I went to the test email tab and got this error.
    Fatal error: Cannot redeclare class phpmailerException in /home/cguildgnw/public_html/wp-includes/class-phpmailer.php on line 4040

    The first tab shows smtp in the green. Not sure what’s my next step in diagnosing this?

    Reply
    • @Fady, The plugin really doesn’t authenticate with password. So that may not be the issue. Please remove access from your app and do a reauthorisation to see how it goes (see the free authorisation section for details).

      Reply
  13. I don’t have any error message when I sent out the test email. But nothing reached out to the test email target. This happened after I changed my gmail password. I did delete the original credential and recreated a new one following the steps in this post. Here is the output of sending the test email:
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “250-smtp.gmail.com at your service, [54.149.110.67]”
    SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [54.149.110.67]”
    SMTP -> get_lines(): $str is “250-SIZE 35882577”
    SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [54.149.110.67]250-SIZE 35882577”
    SMTP -> get_lines(): $str is “250-8BITMIME”
    SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [54.149.110.67]250-SIZE 35882577250-8BITMIME”
    SMTP -> get_lines(): $str is “250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH”
    SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [54.149.110.67]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH”
    SMTP -> get_lines(): $str is “250-ENHANCEDSTATUSCODES”
    SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [54.149.110.67]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES”
    SMTP -> get_lines(): $str is “250-PIPELINING”
    SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [54.149.110.67]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING”
    SMTP -> get_lines(): $str is “250-CHUNKING”
    SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [54.149.110.67]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING”
    SMTP -> get_lines(): $str is “250 SMTPUTF8”
    SERVER -> CLIENT: 250-smtp.gmail.com at your service, [54.149.110.67]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
    Auth method requested: XOAUTH2
    Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
    CLIENT -> SERVER: QUIT
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “221 2.0.0 closing connection 4sm13072674pfe.88 – gsmtp”
    SERVER -> CLIENT: 221 2.0.0 closing connection 4sm13072674pfe.88 – gsmtp
    Connection: closed
    My server info:
    OS: Linux ip-****-generic #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 x86_64
    PHP version: 7.0.15-0ubuntu0.16.04.4
    WordPress version: 4.7.5
    WordPress multisite: No
    openssl: Available
    allow_url_fopen: Enabled
    stream_socket_client: Available
    fsockopen: Available
    cURL: Available
    cURL Version: 7.47.0, OpenSSL/1.0.2g

    Reply
    • I solved this issue by delete the access key and regrant it.

      Reply
  14. Hi, I’ve followed until this:

    13. Click Create. This will generate a Client ID and Client Secret for you. Copy and paste them into the settings area of the plugin.

    But I can’t find the other fields:

    OAuth Email Address
    From Email Address
    From Name
    Type of Encryption
    SMTP Port

    What can I do to find them?
    Thank you.

    Reply
    • @Davide, Once you install and activate the plugin, they appear in the plugin settings (Settings > Gmail SMTP).

      Reply
      • Dear admin,

        thank you very much. It wasn’t clear to me that 14. point and following was about Plugin Settings and not Google Console Settings. Now it works for me!

        Reply
  15. Hi, I’ve had it for a while Running the WP Gmail SMTP plugin with no problems and my WP server was sending Mails correctly.

    To improve safety and following the Google recommendations, change the account settings associate to the API Key, to 2-step verification and from that moment Send mail from WP anymore.
    Revoke and re-create the credentials as it appears in the documentation but the problem was not solved.
    I decided to remove 2-steps-Verification and I came back to configure the Plugin again, from that moment the sending mails works again.

    My question is if anyone knows if it is possible to keep the account safe with the 2-step-verification and also use the WP Gmail SMTP plugin or there is some incompatibility.

    Regards

    Reply
  16. Hi! I’m having a problem with the plugin…
    It is successfully sending emails to the customer, but failing to send to us (the from and to address are the same), but only on cancellations and refunds in WooCommerce (new orders are working fine). This is the error I receive when I cancel a booking with the Woo Bookings plugin:

    Fatal error: Cannot declare class phpmailerException, because the name is already in use in /home/our_domain/public_html/wp-includes/class-phpmailer.php on line 4040

    Refunds are successful but the emails are failing to send, and the site is then hanging (due to an uncaught exception, I guess).

    I find 7 instances of that class being called in your plugin…

    Thanks for any help you can offer.

    Reply
    • Any thoughts @admin?
      I am worried I might have to switch plugins, but I feel like it’s a really simple bug…
      Thanks!

      Reply
  17. i am getting this error:

    Error: redirect_uri_mismatch

    Whats the probelm? i have checked everything is right

    Reply
    • @Aws, Do you have the correct URL set in the “Authorized Redirect URIs” field of your app? Click on the Grant Permission button again and see how it goes.

      Reply
  18. I have a problem after moving my website to new domain.
    I have moved my website to a new domain. It was working perfectly on previous domain. But after I moved I am facing problem sending mails.

    I added the new “Authorized Redirect URI” on the API’s settings on google console. But this did not help.

    If I delete the plugin and then install it again it will not help since all the info is stored on database. Can you tell me where can I find all the plugins related tables on database and delete then and set this plugin up from the beginning?

    Thank you,
    Chris

    Reply
    • @Chris, Did you change the domain name or move to a new web host? Deleting those options is not really necessary as long as the info is correct. Please check the “Fresh Authorization” section so you can do a re-authorization.

      What error do you exactly get?

      Reply
  19. Everything works fine – form submits email through smtp – when testing on localhost (using MAMP) – but doesn’t work when testing on live site – hosted with 1and1.ca. Any suggestions in where this is broken? Using wpforms with gmail smtp. Have changed MX settings to point to gmail. Forms just freeze up and nothing is sent.

    Reply
    • @jeff_ross, So you don’t see any error when you send a test email? Did you check the troubleshooting section?

      Reply
      • Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ‘ssl’ => array ( ‘verify_peer’ => false, ‘verify_peer_name’ => false, ‘allow_self_signed’ => true, ),)

        in reviewing the requirements…it says self hosted wordpress site. what does that mean? I am using 1and1 as my web hosting service…. would that matter….

        Reply
        • @jeff_ross, It means you are using WordPress on a server where you can install a plugin (not wordpress.com).

          Reply
          • I contacted 1and1 and they ended up telling me that i can’t use smtp on a shared server…which i’m apparently on. ahhhh…..

  20. Hello,

    Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ‘ssl’ => array ( ‘verify_peer’ => false, ‘verify_peer_name’ => false, ‘allow_self_signed’ => true, ),)
    Connection: opened
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “220-ns1.bmstar.com ESMTP Exim 4.89 #1 Tue, 15 Aug 2017 18:33:28 -0400 ”
    SMTP -> get_lines(): $data is “220-ns1.bmstar.com ESMTP Exim 4.89 #1 Tue, 15 Aug 2017 18:33:28 -0400 ”
    SMTP -> get_lines(): $str is “220-We do not authorize the use of this system to transport unsolicited, ”
    SMTP -> get_lines(): $data is “220-ns1.bmstar.com ESMTP Exim 4.89 #1 Tue, 15 Aug 2017 18:33:28 -0400 220-We do not authorize the use of this system to transport unsolicited, ”
    SMTP -> get_lines(): $str is “220 and/or bulk e-mail.”
    SERVER -> CLIENT: 220-ns1.bmstar.com ESMTP Exim 4.89 #1 Tue, 15 Aug 2017 18:33:28 -0400 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
    CLIENT -> SERVER: EHLO bmstar.com
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]”
    SMTP -> get_lines(): $str is “250-SIZE 52428800”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800”
    SMTP -> get_lines(): $str is “250-8BITMIME”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800250-8BITMIME”
    SMTP -> get_lines(): $str is “250-PIPELINING”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800250-8BITMIME250-PIPELINING”
    SMTP -> get_lines(): $str is “250-AUTH PLAIN LOGIN”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN”
    SMTP -> get_lines(): $str is “250-STARTTLS”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS”
    SMTP -> get_lines(): $str is “250 HELP”
    SERVER -> CLIENT: 250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
    CLIENT -> SERVER: STARTTLS
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “220 TLS go ahead”
    SERVER -> CLIENT: 220 TLS go ahead
    CLIENT -> SERVER: EHLO bmstar.com
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]”
    SMTP -> get_lines(): $str is “250-SIZE 52428800”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800”
    SMTP -> get_lines(): $str is “250-8BITMIME”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800250-8BITMIME”
    SMTP -> get_lines(): $str is “250-PIPELINING”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800250-8BITMIME250-PIPELINING”
    SMTP -> get_lines(): $str is “250-AUTH PLAIN LOGIN”
    SMTP -> get_lines(): $data is “250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN”
    SMTP -> get_lines(): $str is “250 HELP”
    SERVER -> CLIENT: 250-ns1.bmstar.com Hello bmstar.com [213.155.123.186]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250 HELP
    Auth method requested: XOAUTH2
    Auth methods available on the server: PLAIN,LOGIN
    SMTP Error: Could not authenticate.
    CLIENT -> SERVER: QUIT
    SMTP -> get_lines(): $data is “”
    SMTP -> get_lines(): $str is “221 ns1.bmstar.com closing connection”
    SERVER -> CLIENT: 221 ns1.bmstar.com closing connection
    Connection: closed
    SMTP connect() failed. github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

    and server info:
    OS: Linux ns1.bmstar.com 3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 17:04:51 UTC 2017 x86_64
    PHP version: 5.6.31
    WordPress version: 4.8.1
    WordPress multisite: No
    openssl: Available
    allow_url_fopen: Enabled
    stream_socket_client: Available
    fsockopen: Available
    cURL: Available
    cURL Version: 7.53.1, OpenSSL/1.0.2k

    can you help me please?

    Reply
    • @cebbm, It’s not really connecting to smtp.gmail.com. It seems to be going to ns1.bmstar.com. I believe your server is preventing it from connecting to the gmail SMTP server and is redirecting to ns1.bmstar.com instead. Please contact your web host and they should be able to explain this.

      Reply
      • root@ns1 ~]# telnet smtp.gmail.com 25
        Trying 64.233.167.108…
        Connected to smtp.gmail.com.
        Escape character is ‘^]’.
        220 smtp.gmail.com ESMTP l23sm673156wrb.30 – gsmtp

        it seems server is connecting to gmail and its not a shared hosting but its a cloud hosting which i am managing.

        Reply
        • also my domain provider is godaddy but i dont think this is related to our problem..

          Reply
      • and here is my server MX entry:

        The lowest numbered MX entry currently points to: aspmx.l.google.com
        Email Routing for “bmstar.com” (The domain is owned by “bmstar”).
        Automatically Detect Configuration: (recommended) is selected.

        Reply
      • i solved my problem and want to share for future related problems:

        Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak) : SET (Off)

        Reply

Leave a Comment