SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

unable to send mail from OJS. following error appeared during mail sent. please help
I have upgraded DB OJS 2.4 to OJS 3.3.
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::removeBaseUrl() should not be called statically in /cpanel_data/icebook/public_html/ejournal/plugins/generic/usageStats/UsageStatsLoader.inc.php on line 777
[17-Nov-2021 16:17:59 UTC] PHP Deprecated: Non-static method Core::_getBaseUrlAndPath() should not be called statically in /cpanel_data/icebook/public_html/ejournal/lib/pkp/classes/core/Core.inc.php on line 231
[17-Nov-2021 16:34:37 UTC] Connection: opening to 10.100.3.109:25, timeout=300, options=array()
[17-Nov-2021 16:34:37 UTC] Connection: opened
[17-Nov-2021 16:34:37 UTC] SERVER → CLIENT: 220 SRDELEXG01.ICAR.GOV.IN Microsoft ESMTP MAIL Service ready at Wed, 17 Nov 2021 16:35:39 +0530

[17-Nov-2021 16:34:37 UTC] CLIENT → SERVER: EHLO ebook.icar.gov.in

[17-Nov-2021 16:34:37 UTC] SERVER → CLIENT: 250-SRDELEXG01.ICAR.GOV.IN Hello [10.100.7.171]

250-SIZE 31457280

250-PIPELINING

250-DSN

250-ENHANCEDSTATUSCODES

250-STARTTLS

250-8BITMIME

250-BINARYMIME

250 CHUNKING

[17-Nov-2021 16:34:37 UTC] CLIENT → SERVER: STARTTLS

[17-Nov-2021 16:34:37 UTC] SERVER → CLIENT: 220 2.0.0 SMTP server ready

[17-Nov-2021 16:34:37 UTC] Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed [/cpanel_data/icebook/public_html/ejournal/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 455]
[17-Nov-2021 16:34:37 UTC] SMTP Error: Could not connect to SMTP host.
[17-Nov-2021 16:34:37 UTC] CLIENT → SERVER: QUIT

[17-Nov-2021 16:34:37 UTC] SERVER → CLIENT:
[17-Nov-2021 16:34:37 UTC] SMTP ERROR: QUIT command failed:
[17-Nov-2021 16:34:37 UTC] Connection: closed
[17-Nov-2021 16:34:37 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
[17-Nov-2021 16:34:37 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
mail error

After ssl uncomment error
[17-Nov-2021 16:41:12 UTC] Connection: opening to ssl://10.100.3.109:25, timeout=300, options=array()
[17-Nov-2021 16:41:12 UTC] Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:ssl3_get_record:wrong version number [/cpanel_data/icebook/public_html/ejournal/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[17-Nov-2021 16:41:12 UTC] Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [/cpanel_data/icebook/public_html/ejournal/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[17-Nov-2021 16:41:12 UTC] Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://10.100.3.109:25 (Unknown error) [/cpanel_data/icebook/public_html/ejournal/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[17-Nov-2021 16:41:12 UTC] SMTP ERROR: Failed to connect to server: (0)
[17-Nov-2021 16:41:12 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
[17-Nov-2021 16:41:12 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

mail error 1

Hi @shantanusingh,

Can you please indicate what specific version you are upgrading to (e.g. 3.3.0-8)?

Thank you,

Roger
PKP Team

Thank you for your attention.
I have upgraded from OJS 2.4.8 to OJS 3.2.1 and after that OJS 3.2.1 to OJS 3.3.0-7.

Query
Can we switch finally to the OJS 3.3.0.8? Is this a stable version?

Hi @shantanusingh,

Yes - 3.3.0-8 is the current stable release. I’ll see if some of our other team members can assist with this when the are available.

Best regards,

-Roger
PKP Team

1 Like

Hi @shantanusingh

Those lines are the ones that I think are relevant:


[17-Nov-2021 16:34:37 UTC] Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed [/cpanel_data/icebook/public_html/ejournal/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 455]
[17-Nov-2021 16:34:37 UTC] SMTP Error: Could not connect to SMTP host.

As you can read, there is a problem with the certificate between your host provider and the smtp server (probably are not from the same company)?

It’s something difficult to trace.

Did you try with “smtp_suppress_cert_check = On”?
Is an undocumented variable that was introduced in 3.2 or so and it could do some magic here.

If not, your will probably need to ask first your hosting company telling them about your smtp server.

Cheers,
m.

Thank you for your reply.
We will ask to host provider and confirm you.

This mail received from web hosting provider. please suggest where to implement this and what code to change. Thank You

Dear Sir,
Greetings!
With reference to query given in trail mail, provided error is related with source code.
We have already configured SMTP service on web server.
Kindly refer the below mentioned link for troubleshooting in source code.

Please check and confirm.

I have been trying to connect with gmail SMTP using ssl and tls, while it’s working on localhost but on the server it’s not working and following error is appearing when I’m trying to connect on server. folder permission is 777. Please suggest the solution for the same.

mail erri

[23-Nov-2021 12:10:02 UTC] Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array()
[23-Nov-2021 12:14:16 UTC] Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Connection timed out) [/cpanel_data/icebook/public_html/ejournal/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[23-Nov-2021 12:14:16 UTC] SMTP ERROR: Failed to connect to server: Connection timed out (110)
[23-Nov-2021 12:14:16 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
[23-Nov-2021 12:14:16 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

[23-Nov-2021 12:18:11 UTC] Connection: opening to smtp.gmail.com:587, timeout=300, options=array()
[23-Nov-2021 12:22:25 UTC] Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.gmail.com:587 (Connection timed out) [/cpanel_data/icebook/public_html/ejournal/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[23-Nov-2021 12:22:25 UTC] SMTP ERROR: Failed to connect to server: Connection timed out (110)
[23-Nov-2021 12:22:25 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
[23-Nov-2021 12:22:25 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

[23-Nov-2021 12:32:09 UTC] Connection: opening to smtp.gmail.com:587, timeout=300, options=array()
[23-Nov-2021 12:36:23 UTC] Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.gmail.com:587 (Connection timed out) [/cpanel_data/icebook/public_html/ejournal/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[23-Nov-2021 12:36:23 UTC] SMTP ERROR: Failed to connect to server: Connection timed out (110)
[23-Nov-2021 12:36:23 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
[23-Nov-2021 12:36:23 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

[23-Nov-2021 12:45:36 UTC] Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array()
[23-Nov-2021 12:49:50 UTC] Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Connection timed out) [/cpanel_data/icebook/public_html/ejournal/lib/pkp/lib/vendor/phpmailer/phpmailer/src/SMTP.php line 375]
[23-Nov-2021 12:49:50 UTC] SMTP ERROR: Failed to connect to server: Connection timed out (110)
[23-Nov-2021 12:49:50 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub
[23-Nov-2021 12:49:50 UTC] SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

The code is fine. I’m sorry to say this sounds like a sad excuse from your hosting provider.
I mean… OJS is installed in more 25.000 places and plenty of them use gmail to relay mails without no problem.

To be sure we are doing this in the right way, follow this step by step process:

  1. We need to be completely sure you have the right credentials, so logout and reLOGIN again to gmail.com and check your user/pwd twice.
  2. Configure your account to let third party apps use gmail as a sender going to this web and setting this to ON.
  3. Check your config.inc.php to be
    smtp = On
    smtp_server = "ssl://smtp.gmail.com"
    smtp_port = 465
    smtp_auth = ssl
    smtp_username = "yourGmailUser@gmail.com"
    smtp_password = "yourGmailPassword"
    smtp_suppress_cert_check = On
    

Recently Google changed the authentication method so, to be completely sure it works, I checked this configuration in my testing server and I can tell you TODAY this works for sure.

Cheers,
m.

Thank you for your reply. I think it’s sever side problem and we will contact with the provider.

Query
Can we try the SSL settings in the way shown bellow snapshot.
For this type error Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

Screenshot_2021-11-24-19-30-13-57_40deb401b9ffe8e1df2f1cc5ba480b12