New in CWP Edge-LatestFree with every CWPpro licenceWebsites up to 300x faster

CWP now includes LSPHP, LSCache and CWP CageFS at no extra cost with all CWPpro licences. The LSCache plugin is integrated into our WordPress and other script installers, and CWP CageFS gives every user complete isolation. Available now in the CWP Edge-Latest version.

Get CWPpro ›

Zend Mail Protocol Exception: Could not open socket

Started by fafamonge, June 19, 2019, 10:10:33 PM

Previous topic - Next topic

fafamonge

My app require a library from Zend Mail but when try to send the mail get the following error:

Zend Mail Protocol Exception: Could not open socket

The code related to this message:

    protected function _connect($remote)
    {
        $errorNum = 0;
        $errorStr = '';

        // open connection
        $this->_socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);

        if ($this->_socket === false) {
            if ($errorNum == 0) {
                $errorStr = 'Could not open socket';
            }
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception($errorStr);
        }

        if (($result = $this->_setStreamTimeout(self::TIMEOUT_CONNECTION)) === false) {
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception('Could not set stream timeout');
        }

        return $result;
    }


My Zend Mail cfg:

email.host                          = myhost.mydomain.com
email.smtp_auth                 = true
email.username                  = mail@mydomain.com
email.password                   = mypasswd
email.smtpport                   = 465
email.secure                       = ssl
email.ack                           = false
email.use_local_sendmail    = false


Transport layer is okay:
[root@central /]# php -r 'print_r(stream_get_transports());'
Array
(
    [0] => tcp
    [1] => udp
    [2] => unix
    [3] => udg
    [4] => ssl
    [5] => sslv3
    [6] => sslv2
    [7] => tls
    [8] => tlsv1.0
    [9] => tlsv1.1
    [10] => tlsv1.2
)


Module OpenSSL is working:
[root@central /]# php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
ionCube Loader
json
libxml
mbstring
mcrypt
mysql
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]
the ionCube PHP Loader + ionCube24


Using PHP5.6, Apache 2.4 and MariaDB 10.1

Sandeep


fafamonge

Yes, I tried Port 25, 465, 587, SSL, TLS and all its combination, not luck.