I was using PHPMailer to send an email with SMTP. This time I used PHP 5.6. I received the following error.
Warning: stream_socket_enable_crypto(): Peer certificate CN=`*.example1.com' did not match expected CN=`mail.example2.com' in /usr/share/php/libphp-phpmailer/class.smtp.php on line 344
Researching this led me to this question, that mentions the PHPMailer docs which say this:
In a change from earlier versions, PHP 5.6 verifies certificates on SSL connections. If the SSL config of the server you are connecting to is not correct, you will get an error like this:
It has this work around suggested:
$mail->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) );
But it goes on to say
...this is not recommended: You can also change these settings globally in your php.ini, but that's a really bad idea; PHP 5.6 made this change for very good reasons.
What are those very good reasons?