protected function _expect($code, $timeout = null)
    {
        $this->_response = array();
        $cmd  = '';
        $more = '';
        $msg  = '';
        $errMsg = '';

        if (!is_array($code)) {
            $code = array($code);
        }

        // Borrowed from the Zend Email Library
        do {
            $result = $this->_receive($timeout);
            list($cmd, $more, $msg) = preg_split('/([\s-]+)/', $result, 2, PREG_SPLIT_DELIM_CAPTURE);

            if ($errMsg !== '') {
                $errMsg .= ' ' . $msg;
            } elseif ($cmd === null || !in_array($cmd, $code)) {
                $errMsg = $msg;
            }
        } while (strpos($more, '-') === 0); // The '-' message prefix indicates an information string instead of a response string.

        if ($errMsg !== '') {
            $this->rset();
            throw new SMTPException($errMsg);
        }

        return $msg;
    }
protected function _expect($code, $timeout = null)
    {
        $this->_response = array();
        $cmd  = '';
        $more = '';
        $msg  = '';
        $errMsg = '';

        if (!is_array($code)) {
            $code = array($code);
        }

        // Borrowed from the Zend Email Library
        do {
            $result = $this->_receive($timeout);
            list($cmd, $more, $msg) = preg_split('/([\s-]+)/', $result, 2, PREG_SPLIT_DELIM_CAPTURE);

            if ($errMsg !== '') {
                $errMsg .= ' ' . $msg;
            } elseif ($cmd === null || !in_array($cmd, $code)) {
                $errMsg = $msg;
            }
        } while (strpos($more, '-') === 0); // The '-' message prefix indicates an information string instead of a response string.

        if ($errMsg !== '') {
            $this->rset();
            throw new SMTPException($errMsg);
        }

        return $msg;
    }
protected function _expect ( $ code , $ timeout = null ) { $ this -> _response = array ( ) ; $ cmd = '' ; $ more = '' ; $ msg = '' ; $ errMsg = '' ; if ( ! is_array ( $ code ) ) { $ code = array ( $ code ) ; } // Borrowed from the Zend Email Library do { $ result = $ this -> _receive ( $ timeout ) ; list ( $ cmd , $ more , $ msg ) = preg_split ( '/([\s-]+)/' , $ result , 2 , PREG_SPLIT_DELIM_CAPTURE ) ; if ( $ errMsg !== '' ) { $ errMsg .= ' ' . $ msg ; } elseif ( $ cmd === null || ! in_array ( $ cmd , $ code ) ) { $ errMsg = $ msg ; } } while ( strpos ( $ more , '-' ) === 0 ) ; // The '-' message prefix indicates an information string instead of a response string. if ( $ errMsg !== '' ) { $ this -> rset ( ) ; throw new SMTPException ( $ errMsg ) ; } return $ msg ; }
Parse server response for successful codes

Read the response from the stream and check for expected return code.

@throws SMTPException
@param  string|array $code
One or more codes that indicate a successful response
@param integer $timeout
Per-request timeout value if applicable. Defaults to null which
will not set a timeout.
@return string
Last line of response string
Parse server response for successful codes