SMTP Error - stream_socket_enable_crypto(): Peer certificate CN did not match expected CN

Slavik

XenForo moderator
Staff member
Posting this up for reference to be found easily.

A lot of people upgrading to PHP 5.6+ are running into the following error:

ErrorException: Email to [email address] failed: stream_socket_enable_crypto(): Peer certificate CN=`[hostname]' did not match expected CN=`[target hostname]' - library/Zend/Mail/Protocol/Smtp.php:206

As of PHP 5.6 peer verification is enabled by default (http://php.net/manual/en/migration56.openssl.php).

If you are running WHM or Plesk, I found the issue could be resolved as follows:

WHM: Change the “Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)” from “On” to “Off”.

Plesk: Create a new subscription with the URL set as the server host address, then assign it a SSL cert via the lets encrypt plugin.
 
Plesk: Create a new subscription with the URL set as the server host address, then assign it a SSL cert via the lets encrypt plugin.

Or,
if everything has worked so far under Plesk and the error occurs after renewing the certificate, then first check the settings under: (Replace YourID with your Plesk DomainID) "/modules/sslit/index.php/index/certificate/id/YourID".

It could be that there, the domain, is no longer assigned an email certificate.
If so, click on the tab advanced settings and activate "protect webmail" and/or "protect email".

Thanks to @Slavik your hint put me to the right way before I mess up all my mail settings in XF ;)
 
Hi,
"WHM: Change the “Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)” from “On” to “Off”."
this works for me for my forum , i am using private mail but the other websites on the server cannot send emails anymore from local smtp
 
Hi,
"WHM: Change the “Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak)” from “On” to “Off”."
this works for me for my forum , i am using private mail but the other websites on the server cannot send emails anymore from local smtp

Check out my new guide here

 
Top Bottom