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 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)
- Go to Plugins->Add New from your WordPress admin dashboard
- Search for “gmail smtp naa986”
- Click Install once you have found it
Option 2 (Manual install)
- Download the zip version of the plugin
- Go to Plugins->Add New
- Click Upload Plugin
- Select the zip file on your computer
- Install it
Gmail SMTP Configuration
In order to get started with the plugin go to Settings->Gmail SMTP from your admin dashboard.
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.
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.
3. Choose how you want to configure and register your app. Since I’m not using G Suite I had to choose External.
4. Enter a name (e.g. Gmail SMTP) for the OAuth consent screen.
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.
6. Skip the Scopes screen.
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Hi,
My hosting provider says port 587 TLS is open by default!!!?
I tried all the possibility options (with or without this: Disable SSL Certificate Verification) Also tried with port 26 but still doesn’t work!
Below are Errors for ports 465 SSL and 587 TLS. Any other suggestion on using Google SMTP with API?
Thanks
Nik
————————————————————————–
OS: Linux box354.bluehost.com 3.10.0-614.10.2.lve1.4.50.el6h.x86_64 #1 SMP Mon May 22 17:31:11 EDT 2017 x86_64
PHP version: 7.0.12
WordPress version: 4.8.2
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
————————————————————————–
2017-10-08 19:07:27 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ()
2017-10-08 19:11:41 Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Network is unreachable) [/*****/*****/public_html/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php line 292]
2017-10-08 19:11:41 SMTP ERROR: Failed to connect to server: Network is unreachable (101)
SMTP connect() failed. github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
————————————————————————–
2017-10-08 19:01:27 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
2017-10-08 19:05:41 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.gmail.com:587 (Network is unreachable) [/*******/********/public_html/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php line 292]
2017-10-08 19:05:41 SMTP ERROR: Failed to connect to server: Network is unreachable (101)
SMTP connect() failed. github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
————————————————————————-
@Nik, The debug message is saying otherwise. Most web hosts say ports are open even when they are blocked.
I’m also on bluehost. Did you ever figure this out?
I just got confirmation from Bluehost themselves that they do not support smtp.gmail.com. They want you to use their smtp server.
Nope, I couldn’t make it work!
If their SMTP Servers are in blacklist with a very bad reputation for sending e-mails then they should allow their clients to use different options!
Anyway, they also have some different good SMTP and I think that’s what I am using at the moment to send e-mails to inbox!
Hi All,
Everything is working brilliantly for me, apart from the password reset function now not working for me.
If I try to use the wordpress password reset function I get the following error message:
The email could not be sent.
Possible reason: your host may have disabled the mail() function.
Do you know how to fix this?
Thanks a lot!
Dave
Plugin is conflicting with Caldera Forms (Caldera Labs) and/or WP E-Signature (Approve Me).
When I send a test email, it sits for a long time, then times out with an error of “Page unavailable at this time”
When I try to submit a form, the spinner just sits there and never passes the form information to the E-Signature platform.
When I remove the plug-in.
host says “use port 587 TLS” but I get this error when sending the test email.
2017-10-13 20:47:18 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
2017-10-13 20:47:21 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.gmail.com:587 (Connection refused) [/home/xxx/public_html/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php line 293]
2017-10-13 20:47:21 SMTP ERROR: Failed to connect to server: Connection refused (111)
thanks
never mind… the host tweaked it and it seems to be working… I can’t delete my comment.
I was using 1.1.5. I was unable to send emails. The error is below. I tried to refresh the authorization, however when trying to grant access I received a 500 error on the redirect back after accepting.
I went back to 1.1.2 and it resolved the issue.
Cheers
2017-10-17 10:47:21 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [an IP here]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2017-10-17 10:47:21 Auth method requested: XOAUTH2
2017-10-17 10:47:21 Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
2017-10-17 10:47:21 CLIENT -> SERVER: QUIT
2017-10-17 10:47:21 SMTP -> get_lines(): $data is “”
2017-10-17 10:47:21 SMTP -> get_lines(): $str is “”
2017-10-17 10:47:21 SERVER -> CLIENT:
2017-10-17 10:47:21 SMTP ERROR: QUIT command failed:
2017-10-17 10:47:21 Connection: closed
I tried updating to 1.1.7, and had the same issue. Unable to send using the test same as error above. I tried refreshing and received a 500 error on the redirect back after accepting.
Going back to 1.1.2 resolved the issue. Any suggestions on how to diagnose the issue? I am keen to move off 1.1.2
I installed this to use with Contact Form 7. I am able to send and receive a test email using the plugin test panel. However, when I fill out the contact 7 form – I do not receive the message – despite Contact form 7 saying the message had been sent successfully. Am I missing a setting?
Hello, I am running wordpress on apache (using virtualhost and virtual URL) and installed gmail SMTP plugin.
When I sent test mail, no error. But I just could not receive any email.
When I examined the Server Info, I found that cURL is not available (but I do enable the curl extension in php.ini), What may be the problem then?
Please help me out, thanks!!
Hello, I tried looking through everyone’s comments and questions but did not find this. This is the error I am receiving. Can you help? Thank YOU!
Parse error: syntax error, unexpected ‘[‘ in /home/content/55/10886055/html/coastal/wp-content/plugins/gmail-smtp/google-api-php-client/vendor/guzzlehttp/psr7/src/functions.php on line 78
@Sarah, Are you using PHP 5.6 or higher?
i done everything but all my sending email goes to spam what can i do please
@zaak, Unfortunately, the plugin has no control over whether it will go to the spam folder.
I have been using this plug-in for over a year on my site. Recently I ran into trouble. Long story short, it was ultimately about the host not upgrading their PHP, which they corrected at my request (sounds like I need to move on from there….). In any case, in my efforts to get the plug-in to work again, I actually did have to completely de-authorize it and give it a completely new oAuth setup.
Having done that, the test email went through nicely.
However, when I run my contact form using Contact Form 7, the submit button causes the processing spinner to sit and spin. It spun for about an hour and a half the second time I tried it before I finally just closed the window. The first time was similar, but I only watched the spinning gizmo for a couple of minutes.
There was no error anywhere. So, I just re-ran a test email and…guess what; error! Here’s the debug log:
2017-11-12 22:50:47 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ‘ssl’ => array ( ‘verify_peer’ => false, ‘verify_peer_name’ => false, ‘allow_self_signed’ => true, ),)
2017-11-12 22:50:47 Connection: opened
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “220 smtp.gmail.com ESMTP a45sm3982236otj.73 – gsmtp”
2017-11-12 22:50:47 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP a45sm3982236otj.73 – gsmtp
2017-11-12 22:50:47 CLIENT -> SERVER: EHLO [my website URI]
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-smtp.gmail.com at your service, [[an ip address]]”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-SIZE 35882577”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-8BITMIME”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-STARTTLS”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-STARTTLS”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-ENHANCEDSTATUSCODES”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-PIPELINING”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-CHUNKING”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250 SMTPUTF8”
2017-11-12 22:50:47 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2017-11-12 22:50:47 CLIENT -> SERVER: STARTTLS
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “220 2.0.0 Ready to start TLS”
2017-11-12 22:50:47 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2017-11-12 22:50:47 CLIENT -> SERVER: EHLO [my website URI]
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-smtp.gmail.com at your service, [[an ip address]]”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-SIZE 35882577”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-8BITMIME”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-ENHANCEDSTATUSCODES”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-PIPELINING”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250-CHUNKING”
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “250 SMTPUTF8”
2017-11-12 22:50:47 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [[an ip address]]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2017-11-12 22:50:47 Auth method requested: XOAUTH2
2017-11-12 22:50:47 Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
2017-11-12 22:50:47 CLIENT -> SERVER: QUIT
2017-11-12 22:50:47 SMTP -> get_lines(): $data is “”
2017-11-12 22:50:47 SMTP -> get_lines(): $str is “221 2.0.0 closing connection a45sm3982236otj.73 – gsmtp”
2017-11-12 22:50:47 SERVER -> CLIENT: 221 2.0.0 closing connection a45sm3982236otj.73 – gsmtp
2017-11-12 22:50:47 Connection: closed
Fatal error: Uncaught exception ‘InvalidArgumentException’ with message ‘Invalid token format’ in /home/[my website folder name]/public_html/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Client.php:434 Stack trace: #0 /home/[my website folder name]/public_html/wp-content/plugins/gmail-smtp/class.phpmaileroauthgoogle.php(138): Google_Client->setAccessToken(‘{“error”:”inval…’) #1 /home/[my website folder name]/public_html/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php(470): GmailXOAuth2->getOauth64() #2 /home/[my website folder name]/public_html/wp-content/plugins/gmail-smtp/class.phpmaileroauth.php(153): SMTP->authenticate(”, ”, ‘XOAUTH2’, ”, ”, Object(GmailXOAuth2)) #3 /home/[my website folder name]/public_html/wp-content/plugins/gmail-smtp/PHPMailer/class.phpmailer.php(1540): PHPMailerOAuth->smtpConnect(Array) #4 /home/[my website folder name]/public_html/wp-content/plugins/gmail-smtp/PHPMailer/class.phpmailer.php(1335): PHPMailer->smtpSend(‘Date: Sun, 12 N…’, ‘5:50 PMn’) #5 /home/[my website folder name]/public_html/wp-content/plugins/gmail-smtp/PHPMailer/class.phpmail in /home/[my website folder name]/public_html/wp-content/plugins/gmail-smtp/google-api-php-client/src/Google/Client.php on line 434
And, here’s the server config:
OS: Linux isuzu.websitewelcome.com 3.10.0-714.10.2.lve1.4.66.el6h.x86_64 #1 SMP Mon Oct 9 19:41:36 EDT 2017 x86_64
PHP version: 5.6.30
WordPress version: 4.8.3
WordPress multisite: No
openssl: Available
allow_url_fopen: Enabled
stream_socket_client: Available
fsockopen: Available
cURL: Available
cURL Version: 7.19.7, NSS/3.27.1
I am working locally on xampp and using Gmail SMTP plugin to get my contact form 7 to work. When i try sending a test email it fails, and i get this error message:
Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [C:xampp1htdocsWPwp-contentpluginsgmail-smtpPHPMailerclass.smtp.php line 369]
SMTP Error: Could not connect to SMTP host.
SMTP connect() failed. github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
I changed the mail function settings in php.ini and sendmail configuration accordingly. Can you help me with what the problem might be here?
@Jzg, Disable SSL Certificate Verification in the Gmail SMTP settings and see how it goes.
I am getting the same error:
Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [/home/[site name]/public_html/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php line 375]
@Kirk, Please check Error #5 in the Troubleshooting section.
hello @Admin
whenever i proceed for grant permission button this error occured.
“currently unable to handle this request.
HTTP ERROR 500”
is any solution for this issue
Hi,
I have configurated all like you said. Unfortunately, in Test Email section, I always read this: (I’ve already tried to change port and from TLS to SSL many times)
2017-11-14 15:51:56 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
2017-11-14 15:51:58 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.gmail.com:587 (Connection refused) [/home/content/n3pnexwpnas02_data03/63/41199263/html/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php line 294]
2017-11-14 15:51:58 SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
What I did wrong?
Help me đ
Thank you so much!
@Silvia, Please copy and paste the “Server Info” part of the settings so I check it.
Hi, I tryes just two minutes ago and I see this:
2017-11-15 09:47:24 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
2017-11-15 09:47:26 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.gmail.com:587 (Connection refused) [/home/content/n3pnexwpnas02_data03/63/41199263/html/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php line 294]
2017-11-15 09:47:26 SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed
With this server info:
OS: Linux n3nlwpweb027.prod.ams3.secureserver.net 2.6.32-673.26.1.lve1.4.30.el6.nfsfixes.x86_64 #1 SMP Wed Jul 26 10:28:40 MST 2017 x86_64
PHP version: 5.6.30
WordPress version: 4.8.3
WordPress multisite: No
openssl: Available
allow_url_fopen: Enabled
stream_socket_client: Available
fsockopen: Available
cURL: Available
cURL Version: 7.45.0, OpenSSL/1.0.1e
From address not being used, from line shows the OAuth Email Address and not the from address. No matter what I change in the app setup or the plugin setup it will only show the OAuth address as the return, and changing that breaks the auth.
@Rich, https://wordpress.org/support/topic/the-email-address-which-will-be-used-a/
I use the Gmal SMTP plugin with a wp form plugin and works great.
Is there a way to send email directly out of a PHP code through the Gmal SMTP plugin (without using any form) instead of using the phpmail function?
@Frank, For testing purpose you can use the “Test Email” function in the plugin. If you want to manually send an email from your custom PHP code (running on WordPress) you just need to call the wp_mail function.
Hi,
Iâm trying to setup my WP site, to work with your gmail plugin, but without luck. I canât see any errors in the log:
2017-11-20 14:38:45 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ()
2017-11-20 14:38:45 Connection: opened
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “220 smtp.gmail.com ESMTP i6sm7553477edk.3 – gsmtp”
2017-11-20 14:38:45 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP i6sm7553477edk.3 – gsmtp
2017-11-20 14:38:45 CLIENT -> SERVER: EHLO icuc.uk
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “250-smtp.gmail.com at your service, [77.104.173.217]”
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [77.104.173.217]”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “250-SIZE 35882577”
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [77.104.173.217]250-SIZE 35882577”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “250-8BITMIME”
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [77.104.173.217]250-SIZE 35882577250-8BITMIME”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH”
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [77.104.173.217]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “250-ENHANCEDSTATUSCODES”
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [77.104.173.217]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “250-PIPELINING”
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [77.104.173.217]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “250-CHUNKING”
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “250-smtp.gmail.com at your service, [77.104.173.217]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “250 SMTPUTF8”
2017-11-20 14:38:45 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [77.104.173.217]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2017-11-20 14:38:45 Auth method requested: XOAUTH2
2017-11-20 14:38:45 Auth methods available on the server: LOGIN,PLAIN,XOAUTH2,PLAIN-CLIENTTOKEN,OAUTHBEARER,XOAUTH
2017-11-20 14:38:45 CLIENT -> SERVER: QUIT
2017-11-20 14:38:45 SMTP -> get_lines(): $data is “”
2017-11-20 14:38:45 SMTP -> get_lines(): $str is “221 2.0.0 closing connection i6sm7553477edk.3 – gsmtp”
2017-11-20 14:38:45 SERVER -> CLIENT: 221 2.0.0 closing connection i6sm7553477edk.3 – gsmtp
2017-11-20 14:38:45 Connection: closed
Server info:
OS: Linux ukm17.siteground.biz 3.12.18-clouder0 #85 SMP Mon Apr 3 10:28:14 EEST 2017 x86_64
PHP version: 5.6.32
WordPress version: 4.9
WordPress multisite: No
openssl: Available
allow_url_fopen: Enabled
stream_socket_client: Available
fsockopen: Available
cURL: Available
cURL Version: 7.53.0, OpenSSL/1.0.2k
Any help would be very much appreciated as I have tried everything I can think of!!
Regards, Colin
I too have this issue. If I revoke access, and then reconnect to gmail, everything works again. After a period of time mail stops working. If I revoke access and reconnect it will work again. No other changes being made to the site at all. Suggestions? Anyone?
Tried to setup the plugin, but test message won’t go through with the following log. I didn’t get a hacking etc. email to my Gmail inbox, thus couldn’t solve this that way. Any ideas?
2017-11-21 15:57:51 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ()
2017-11-21 15:57:53 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.gmail.com:587 (Network is unreachable) [/home/niskatku/eroonjumeista.fi/wp-content/plugins/gmail-smtp/PHPMailer/class.smtp.php line 298]
2017-11-21 15:57:53 SMTP ERROR: Failed to connect to server: Network is unreachable (101)
SMTP connect() failed. github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
@Joonas, Please contact your web host to make sure that port 587 is open and supports TLS encryption.
Did exactly that and everything works now. Thank you!
Hi,
I tried to use your plugin, i setup everything like the documentation :
I grant access with Google Api, i also authorize access to application with my gmail address.
I tried different settings, with SSL/TLS and more and i can’t send the test message.
I wait a while and i get this message on a new page :
“The page you are looking for is temporarily unavailable.
Please try again later.
bd31bb1418396b4822106482ef381729 ead27eb68c47cb3084e806e9f0f59646 883e377a5cb33ec683bf6a99c4a121c5 ”
So i don’t know what to change or try, my server info :
“OS: Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
PHP version: 7.0.25
WordPress version: 4.8.3
WordPress multisite: No
openssl: Available
allow_url_fopen: Enabled
stream_socket_client: Available
fsockopen: Available
cURL: Available
cURL Version: 7.38.0, OpenSSL/1.0.1t”
Thank you for your help !
It’s ok, i tried with another hosting and it works, the port 465 is blocked on another website and hosting so i asked this hosting to unlock it.
Awesome article!
G’day,
Am trying your awesome plug-in but unable to send a test email from it. it seems like Gmail is only allowing Plain and Login types of connection. The following is received:
2017-11-27 01:07:07 Auth method requested: XOAUTH2
2017-11-27 01:07:07 Auth methods available on the server: PLAIN,LOGIN
SMTP Error: Could not authenticate.
2017-11-27 01:07:07 CLIENT -> SERVER: QUIT
OS: Linux 4.4.51-40.58.amzn1.x86_64 #1 SMP Tue Feb 28 21:57:17 UTC 2017 x86_64
PHP version: 5.6.26
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.38.0, OpenSSL/1.0.1k
Am happy to send complete error and any diagnostic results via private email. More than happy to give the 5-star rating if we can get this to work.
@Jason, Please use the contact form to send the full debug data so I can help troubleshoot this issue.
G’day Admin …
I got it figured and working. First some background. The Website (with WP) in question lives on a C-Panel / WHM server. logging into the WHM console, I ultimately found that under the Security Centre, there is a sub-menu called SMTP Restrictions. By Default, SMTP access to external servers is restricted to MTA, mailman and root accounts (root is unix/linux equivalent to administrator). Disabling this restriction allows the plug-in to work as advertised.
Awsome job đ
Jason!!!! You are a star. I’ve spent most of the weekend trying to figure out why Gmail SMTP stopped working. I’ve read all I can about the plugin (it’s been very dull) and I just fell over your post (just after writing a reply to the post below). In a second your post sorted it out for me. Thank you very much indeed.
Did you get anywhere with this? I get the same error. I’m absolutely certain that the G Suite end is set up correctly. I’ve remade everything their numerous times, reinstalled plugin, revoked access etc etc, and I’ve dealt with the host too, but having spent hours on this I have drawn a blank. We use the plugin successfully with other sites we control so it’s not as if we have no experience with it.
2017-12-18 07:26:42 Auth method requested: XOAUTH2
2017-12-18 07:26:42 Auth methods available on the server: PLAIN,LOGIN
SMTP Error: Could not authenticate.
2017-12-18 07:26:42 CLIENT -> SERVER: QUIT
OS: Linux ****.****.com 3.4.46-8.el6.centos.alt.x86_64 #1 SMP Wed May 22 01:29:08 UTC 2013 x86_64
PHP version: 5.6.32
WordPress version: 4.9.1
WordPress multisite: No
openssl: Available
allow_url_fopen: Disabled
stream_socket_client: Available
fsockopen: Available
cURL: Available
cURL Version: 7.57.0, OpenSSL/1.0.2m
Wow. And seconds lklater I’ve found the pst abnove and it’s sorted. For other with the dame problem the answer is below.
I have one niggle. How come the WHM SMTP Restriction became enabled. GMail SMTP worked last week and then it just stopped. This suggests that the WHM SMTP Restriction was changed. We control our VSL and it was not us. Was it some sort of automatic security update. Who knows?
“I got it figured and working. First some background. The Website (with WP) in question lives on a C-Panel / WHM server. logging into the WHM console, I ultimately found that under the Security Centre, there is a sub-menu called SMTP Restrictions. By Default, SMTP access to external servers is restricted to MTA, mailman and root accounts (root is unix/linux equivalent to administrator). Disabling this restriction allows the plug-in to work as advertised.”