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();
            }
        }
    }