public function connect($host, $port = null, $ssl = false)
    {
        if ($ssl == 'SSL') {
            $host = 'ssl://' . $host;
        }

        if ($port === null) {
            $port = $ssl === 'SSL' ? 993 : 143;
        }

        $errno  =  0;
        $errstr = '';
        $this->_socket = @fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION);
        if (!$this->_socket) {
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            // require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception('cannot connect to host; error = ' . $errstr .
                                                   ' (errno = ' . $errno . ' )');
        }

        if (!$this->_assumedNextLine('* OK')) {
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            // require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception('host doesn\'t allow connection');
        }

        if ($ssl === 'TLS') {
            $result = $this->requestAndResponse('STARTTLS');
            $result = $result && stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
            if (!$result) {
                /**
                 * @see Zend_Mail_Protocol_Exception
                 */
                // require_once 'Zend/Mail/Protocol/Exception.php';
                throw new Zend_Mail_Protocol_Exception('cannot enable TLS');
            }
        }
    }
public function connect($host, $port = null, $ssl = false)
    {
        if ($ssl == 'SSL') {
            $host = 'ssl://' . $host;
        }

        if ($port === null) {
            $port = $ssl === 'SSL' ? 993 : 143;
        }

        $errno  =  0;
        $errstr = '';
        $this->_socket = @fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION);
        if (!$this->_socket) {
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            // require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception('cannot connect to host; error = ' . $errstr .
                                                   ' (errno = ' . $errno . ' )');
        }

        if (!$this->_assumedNextLine('* OK')) {
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            // require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception('host doesn\'t allow connection');
        }

        if ($ssl === 'TLS') {
            $result = $this->requestAndResponse('STARTTLS');
            $result = $result && stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
            if (!$result) {
                /**
                 * @see Zend_Mail_Protocol_Exception
                 */
                // require_once 'Zend/Mail/Protocol/Exception.php';
                throw new Zend_Mail_Protocol_Exception('cannot enable TLS');
            }
        }
    }
public function connect ( $ host , $ port = null , $ ssl = false ) { if ( $ ssl == 'SSL' ) { $ host = 'ssl://' . $ host ; } if ( $ port === null ) { $ port = $ ssl === 'SSL' ? 993 : 143 ; } $ errno = 0 ; $ errstr = '' ; $ this -> _socket = @ fsockopen ( $ host , $ port , $ errno , $ errstr , self :: TIMEOUT_CONNECTION ) ; if ( ! $ this -> _socket ) { /**
             * @see Zend_Mail_Protocol_Exception
             */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception ( 'cannot connect to host; error = ' . $ errstr . ' (errno = ' . $ errno . ' )' ) ; } if ( ! $ this -> _assumedNextLine ( '* OK' ) ) { /**
             * @see Zend_Mail_Protocol_Exception
             */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception ( 'host doesn\'t allow connection' ) ; } if ( $ ssl === 'TLS' ) { $ result = $ this -> requestAndResponse ( 'STARTTLS' ) ; $ result = $ result && stream_socket_enable_crypto ( $ this -> _socket , true , STREAM_CRYPTO_METHOD_TLS_CLIENT ) ; if ( ! $ result ) { /**
                 * @see Zend_Mail_Protocol_Exception
                 */ // require_once 'Zend/Mail/Protocol/Exception.php'; throw new Zend_Mail_Protocol_Exception ( 'cannot enable TLS' ) ; } } }
Open connection to IMAP server

@param  string      $host  hostname or IP address of IMAP server
@param  int|null    $port  of IMAP server, default is 143 (993 for ssl)
@param  string|bool $ssl   use 'SSL', 'TLS' or false
@return string welcome message
@throws Zend_Mail_Protocol_Exception
Open connection to IMAP server