PHP Classes

PHP 5.6 compatibility

Recommend this page to a friend!

      SMTP E-mail sending class  >  All threads  >  PHP 5.6 compatibility  >  (Un) Subscribe thread alerts  
Subject:PHP 5.6 compatibility
Summary:The class needs to be updated to work with 5.6 new SSL options
Messages:6
Author:Klemen
Date:2014-11-22 17:51:43
 

  1. PHP 5.6 compatibility   Reply   Report abuse  
Picture of Klemen Klemen - 2014-11-22 17:51:43
Hello,

Whenever you try to establish a SSL connection in PHP 5.6 with this class it fails. It needs to be updated to work with PHP 5.6.

Reason: the class connects to an IP addresses, but most SSL certificates are issued out to host names (domains), rather than IP addresses

Because PHP 5.6 now verifies SSL certificates, the "fsockopen" function fails in the "ConnectToHost" method due to mismatched certificate CN (expects host name, but IP is given instead).

If all instances of fsockopen are modified to connect to the host name instead of IP address that seems to fix the issue.

Thank you!

  2. Re: PHP 5.6 compatibility   Reply   Report abuse  
Picture of Klemen Klemen - 2014-11-22 17:59:19 - In reply to message 1 from Klemen
P.s.: your POP3 class works fine in PHP 5.6 exactly because it uses host name to connect rather than host IP address.

  3. Re: PHP 5.6 compatibility   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-23 04:08:41 - In reply to message 1 from Klemen
Yes, the issue was already replied in other topic.

  4. Re: PHP 5.6 compatibility   Reply   Report abuse  
Picture of Klemen Klemen - 2014-11-23 10:10:54 - In reply to message 3 from Manuel Lemos
Thank you for the update!

This indeed fixes SSL connections, but the problem remains when starting TLS over a non-SSL connection (for example TLS over port 25):

$smtp->ssl = 0;
$smtp->start_tls = 1;

So, the hostname should be used instead of the IP when $this->ssl OR $this->start_tls returns true.

Great class though, have been using it for years without any problems at all!

  5. Re: PHP 5.6 compatibility   Reply   Report abuse  
Picture of Klemen Klemen - 2014-11-23 10:15:35 - In reply to message 4 from Klemen
An example that works fine:



if($this->ssl)
$ip = 'ssl://'.($host = $domain);
elseif ($this->start_tls)
$ip=($host = $domain);
else
$host = $ip;


(similar code for socks and proxy)

  6. Re: PHP 5.6 compatibility   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-11-23 22:46:49 - In reply to message 4 from Klemen
Yes, you are right, I missed that use case. It is fixed now. Thank you for reporting.