Ever since PHP 5.6, PHP verifies peer SSL certificates by default when using SSL/TLS connections – previously anything goes.

Some customers making the leap from PHP 5.5 to PHP 7 have encountered issues with sending mail to improperly configured mail servers. Or shared mail servers like cPanel where a correctly configured server is almost impossible.

If you can’t change the mail server, you can change the code.

WordPress uses the popular PHPMailer library to send emails. This snippet will request PHPMailer not to verify the SSL on the peer and allow self signed certificates (not entirely recommended). Feel free to set true/false to suit your requirements. It hooks into phpmailer_init, so place in your functions.php file.

add_action( 'phpmailer_init', function($phpmailer) {
		$phpmailer->SMTPOptions = array(
			'ssl' => array(
				'verify_peer'       => false,
				'verify_peer_name'  => false,
				'allow_self_signed' => true


Ref: http://php.net/manual/en/migration56.openssl.php

Lime Web Development is a small and focused specialist web development agency based in Chorley, Lancashire. We primarily produce PHP web applications in WordPress, WooCommerce and CakePHP.

PHP 7 + phpMailer + WordPress + SSL Connection Errors