protected function _connect($host, $port)
    {
        $errorNum = 0;
        $errorStr = '';

        $remoteAddr = $this->_transport . '://' . $host . ':' . $port;

        if (!is_resource($this->_connection)) {
            $this->_connection = @stream_socket_client($remoteAddr, $errorNum, $errorStr, self::TIMEOUT);

            if ($this->_connection === false) {
                if ($errorNum == 0) {
                    throw new SMTPException(__('Unable to open socket. Unknown error'));
                } else {
                    throw new SMTPException(__('Unable to open socket. %s', array($errorStr)));
                }
            }

            if (@stream_set_timeout($this->_connection, self::TIMEOUT) === false) {
                throw new SMTPException(__('Unable to set timeout.'));
            }

            $this->helo();

            if ($this->_secure == 'tls') {
                $this->_tls();
            }

            if (($this->_user !== null) && ($this->_pass !== null)) {
                $this->_auth();
            }
        }
    }
protected function _connect($host, $port)
    {
        $errorNum = 0;
        $errorStr = '';

        $remoteAddr = $this->_transport . '://' . $host . ':' . $port;

        if (!is_resource($this->_connection)) {
            $this->_connection = @stream_socket_client($remoteAddr, $errorNum, $errorStr, self::TIMEOUT);

            if ($this->_connection === false) {
                if ($errorNum == 0) {
                    throw new SMTPException(__('Unable to open socket. Unknown error'));
                } else {
                    throw new SMTPException(__('Unable to open socket. %s', array($errorStr)));
                }
            }

            if (@stream_set_timeout($this->_connection, self::TIMEOUT) === false) {
                throw new SMTPException(__('Unable to set timeout.'));
            }

            $this->helo();

            if ($this->_secure == 'tls') {
                $this->_tls();
            }

            if (($this->_user !== null) && ($this->_pass !== null)) {
                $this->_auth();
            }
        }
    }
protected function _connect ( $ host , $ port ) { $ errorNum = 0 ; $ errorStr = '' ; $ remoteAddr = $ this -> _transport . '://' . $ host . ':' . $ port ; if ( ! is_resource ( $ this -> _connection ) ) { $ this -> _connection = @ stream_socket_client ( $ remoteAddr , $ errorNum , $ errorStr , self :: TIMEOUT ) ; if ( $ this -> _connection === false ) { if ( $ errorNum == 0 ) { throw new SMTPException ( __ ( 'Unable to open socket. Unknown error' ) ) ; } else { throw new SMTPException ( __ ( 'Unable to open socket. %s' , array ( $ errorStr ) ) ) ; } } if ( @ stream_set_timeout ( $ this -> _connection , self :: TIMEOUT ) === false ) { throw new SMTPException ( __ ( 'Unable to set timeout.' ) ) ; } $ this -> helo ( ) ; if ( $ this -> _secure == 'tls' ) { $ this -> _tls ( ) ; } if ( ( $ this -> _user !== null ) && ( $ this -> _pass !== null ) ) { $ this -> _auth ( ) ; } } }
Connect to the host, and perform basic functions like helo and auth.


@param string $host
@param integer $port
@throws SMTPException
@throws Exception
@return void
Connect to the host and perform basic functions like helo and auth .