Author Topic: Zend Mail Protocol Exception: Could not open socket  (Read 14861 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Zend Mail Protocol Exception: Could not open socket
« on: June 19, 2019, 10:10:33 PM »
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:

Code: [Select]
    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:

Code: [Select]
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:
Code: [Select]
[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:
Code: [Select]
[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

Offline
*****
Re: Zend Mail Protocol Exception: Could not open socket
« Reply #1 on: June 21, 2019, 08:38:35 AM »
did you tried with plain smtp port 25 ?

Offline
*
Re: Zend Mail Protocol Exception: Could not open socket
« Reply #2 on: June 23, 2019, 04:37:01 AM »
Yes, I tried Port 25, 465, 587, SSL, TLS and all its combination, not luck.