PHP 5.6 certificate verification failure

PHP 5.6 certificate verification failure

I found that my php 5.6 has somekind a different approach on handling remote smtp server and based on  php 5.6 certificate verification failure  I need to add this code:
  1. $mail->SMTPOptions = array(
  2.     'ssl' => array(
  3.         'verify_peer' => false,
  4.         'verify_peer_name' => false,
  5.         'allow_self_signed' => true
  6.     )
  7. );
So it allowed  insecure connection and not generating this error (in the server directory log):
PHP Warning:  stream_socket_enable_crypto(): Peer certificate CN=`server.com' did not match expected CN=`smtp.zoho.com' in /somedirectory/class-smtp.php on line 369 (from phpmailer)
which mean if this error is shown the email is not delivered because the connection will get connection refused(111).

But when I do this, very much possible it will end up in the Junk or Spam, I've tested it on outlook.com and gmail.com.

The crying for help:

In the troubleshooting on above link mention "The correct fix for this is to replace the invalid, misconfigured or self-signed certificate with a good one."

Correct me if I'm wrong, from my understanding it need zoho certificate so it will match and enable the encryption.

Can you show me how to fix this.

Thanks in advance.