Title: Problems with PHP version 5.6 or later
Last modified: July 5, 2017

---

# Problems with PHP version 5.6 or later

 *  Resolved [Rodrigo Macedo](https://wordpress.org/support/users/unionforwebdesigner/)
 * (@unionforwebdesigner)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/problems-with-php-version-5-6-or-later/)
 * Hello good day,
 * I’m having trouble using this plugin with PHP version 7, I browsed around the
   plugin support forum, and the only topic I found was about a member asking if
   the plugin was compatible with PHP version 7.
 * Apparently the plugin is compatible with version 7, however it returns the following
   error after configuring and performing the tests:
 *     ```
       Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: 
       error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
   
       Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): Failed to enable crypto
   
       Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to ssl://localhost:465 (Unknown error)
   
       SMTP ERROR: Failed to connect to server:  (0)
   
       SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
       ```
   
 * I ran the tests with all versions available on my server and the plugin itself
   works with versions 5.4 and 5.5, the later versions return this error.
 * Apparently the problem that is happening is the SSL certificate verification 
   as per the PHPMailer documentation:
 * [https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#php-56-certificate-verification-failure](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#php-56-certificate-verification-failure)
 * In the documentation it explains that the correct one would be to replace the
   invalid, badly configured or self-signed certificate, but I have already contacted
   my server and I was informed that it does not have an SSL certificate for email
   shots, so failing that I would use The second option which is in the PHPMailer
   documentation, allow for insecure connections via SMTPOptions.Although it is 
   not recommended, below is a code that can be added:
 *     ```
       $mail->SMTPOptions = array(
           'ssl' => array(
               'verify_peer' => false,
               'verify_peer_name' => false,
               'allow_self_signed' => true
           )
       );
       ```
   
 * I would like to know if you can help me with this, where can I add this code 
   so that you can continue to use PHP version 7?
 * After all it is highly recommended to use more updated versions since version
   5.6 will soon become obsolete in security issues.
 * Thank you in advance.
 * Best regards,

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [ccastilla](https://wordpress.org/support/users/ccastilla/)
 * (@ccastilla)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/problems-with-php-version-5-6-or-later/#post-9300255)
 * Hi, my problem is the same, help me!
 *  Thread Starter [Rodrigo Macedo](https://wordpress.org/support/users/unionforwebdesigner/)
 * (@unionforwebdesigner)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/problems-with-php-version-5-6-or-later/#post-9304997)
 * The Developer or Support of this plugin seems to have abandoned the same, take
   days or even weeks for them to see or respond.
 * Before opening this Topic I’ve been looking at others and had open threads for
   unanswered weeks.
 * By the way, the solution is to try to look for an alternative.
 * If you are having the same problem I think you should not expect too much from
   the developer nor the support of this plugin [@ccastilla](https://wordpress.org/support/users/ccastilla/).
 *  [Reggie Niccolo Santos](https://wordpress.org/support/users/rnsantos007/)
 * (@rnsantos007)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/problems-with-php-version-5-6-or-later/#post-9316090)
 * You can insert the given code in line 148 of wp_mail_smtp.php as follows:
 *     ```
       // If we're sending via SMTP, set the host
       		if (get_option('mailer') == "smtp") {
   
       			// Set the SMTPSecure value, if set to none, leave this blank
       			$phpmailer->SMTPSecure = get_option('smtp_ssl') == 'none' ? '' : get_option('smtp_ssl');
   
       			// Set the other options
       			$phpmailer->Host = get_option('smtp_host');
       			$phpmailer->Port = get_option('smtp_port'); 
   
       			// https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
       			// http://php.net/manual/en/migration56.openssl.php
       			$phpmailer->SMTPOptions = array(
       				'ssl' => array(
       					'verify_peer' => false,
       					'verify_peer_name' => false,
       					'allow_self_signed' => true
       				)
       			);
   
       			// If we're using smtp auth, set the username & password
       			if (get_option('smtp_auth') == "true") {
       				$phpmailer->SMTPAuth = TRUE;
       				$phpmailer->Username = get_option('smtp_user');
       				$phpmailer->Password = get_option('smtp_pass');
       			}
       		} 
       ```
   
 * Just replace `$mail` with `$phpmailer`. Worked for me.
 *  Plugin Author [Slava Abakumov](https://wordpress.org/support/users/slaffik/)
 * (@slaffik)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/problems-with-php-version-5-6-or-later/#post-9781966)
 * It’s relevant for SMTP only with a misconfigured server.
 * You can place this snippet:
    [https://gist.github.com/slaFFik/c1d7d4249f47da7195fb973109952090](https://gist.github.com/slaFFik/c1d7d4249f47da7195fb973109952090)
 * Here is the tutorial on where and how to do that: [http://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/](http://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/)
 * That will allow you to bypass the problem. Not recommended though, as it’s better
   to fix the server configuration.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Problems with PHP version 5.6 or later’ is closed to new replies.

 * ![](https://ps.w.org/wp-mail-smtp/assets/icon-256x256.png?rev=1755440)
 * [WP Mail SMTP by WPForms - The Most Popular SMTP and Email Log Plugin](https://wordpress.org/plugins/wp-mail-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-smtp/reviews/)

## Tags

 * [compatibility](https://wordpress.org/support/topic-tag/compatibility/)
 * [php-7](https://wordpress.org/support/topic-tag/php-7/)
 * [PHP7](https://wordpress.org/support/topic-tag/php7/)
 * [phpmailer](https://wordpress.org/support/topic-tag/phpmailer/)
 * [troubleshooting](https://wordpress.org/support/topic-tag/troubleshooting/)

 * 4 replies
 * 4 participants
 * Last reply from: [Slava Abakumov](https://wordpress.org/support/users/slaffik/)
 * Last activity: [8 years, 5 months ago](https://wordpress.org/support/topic/problems-with-php-version-5-6-or-later/#post-9781966)
 * Status: resolved