SMTP Error: Could not connect to SMTP host. class.smtp.php line 374

Before the upgrade, Email worked fine.
After upgrade to 7.10.4 and a php version upgrade, SMTP test to google APPS system responds

Error:SMTP Error: Could not connect to SMTP host.
3: Connection: opening to smtp.gmail.com:587, timeout=300, options=array (
)
3: Connection: opened
2: SERVER -> CLIENT: 220-host.xxxxxxxx ESMTP Exim 4.89_1 #1 Mon, 30 Apr 2018 17:16:20 -0400 
220-We do not authorize the use of this system to transport unsolicited, 
220 and/or bulk e-mail.
1: CLIENT -> SERVER: EHLO  xxxxxxx
2: SERVER -> CLIENT: 250-host.xxxxxxx.com Hello xxxxxx.com [xx.xxx.xxxx.xxxx]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
1: CLIENT -> SERVER: STARTTLS
2: SERVER -> CLIENT: 220 TLS go ahead
3: Connection failed. Error #2: stream_socket_enable_crypto(): Peer certificate CN=`host.xxxxxxxxxx' did not match expected CN=`smtp.gmail.com' [/home/xxxxxxxxxx/public_html/crm77/include/phpmailer/class.smtp.php line 374]
3: SMTP Error: Could not connect to SMTP host.
1: CLIENT -> SERVER: QUIT
2: SERVER -> CLIENT: 221 host.xxxxxxxx.com closing connection
3: Connection: closed
3: SMTP Error: Could not connect to SMTP host.

Probably the PHP upgrade is causing this difference.

You can Google for that message “Error #2: stream_socket_enable_crypto(): Peer certificate”, you’ll find other people online struggling with that.

You might need to go into Google and select “Allow lwess secure apps”, or you might even need to configure HTTPS for your site and get a proper certificate. Your site will be safer because of this. Check out Let’s Encrypt for free certificates.

1 Like

Got at SSL cert for the site and it worked fine.
Thank you.