Hi,

just trying to use the Zend_Mail_Protocol_Smtp_Auth_Login class directly to 
test user supplied SMTP login details in an installer I am creating for an app.
It keeps failing the auth() call as there is data still in the stream from the 
initial _connect() call which causes the _expect() to fail after AUTH LOGIN is 
sent.
Adding a call to _receive() within _connect() to clear the stream fixes the 
problem for me:

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);
        }
       
        // needed to clear stream
        $this->_receive();
       
        if (($result = stream_set_timeout($this->_socket, 
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;
    }

Am I missing something or is this a fix that is needed??

Cheers,

Brad

Reply via email to