Esempio n. 1
0
        def callback(password):
            # Note that we cheat with the context factory here (value=1),
            # because ssl.connectSSL does it automatically, and in the
            # case of STARTTLS we override esmtpState_starttls above
            # to supply the correct SSL context.
            factory = smtp.ESMTPSenderFactory(username, password, from_addr,
                                              to_addrs, msg,
                                              deferred, retries, timeout,
                                              1, heloFallback, authRequired,
                                              securityRequired)

            factory.protocol = _TwistedESMTPSender
            factory.testing  = testing

            # Convert the Unicode hostname to an str
            # before passing to twisted since twisted uses
            # a repr of the hostname in error messages.
            host = self.account.host.encode("utf-8", "ignore")

            if self.account.connectionSecurity == 'SSL':
                ssl.connectSSL(host, self.account.port, factory,
                               self.view)
            else:
                ssl.connectTCP(host, self.account.port, factory,
                               self.view)
Esempio n. 2
0
    def _connectToServer(self):
        if __debug__:
            trace("_connectToServer")

        if self.cancel:
            return self._resetClient()

        self.view.refresh()

        #Overidden method
        self._getAccount()

        # The isOnline check is performed in the Twisted thread
        # so pass in a view.
        if not Globals.mailService.isOnline(self.view):
            if self.statusMessages:
                msg = constants.MAIL_PROTOCOL_OFFLINE % \
                              {"accountName": self.account.displayName}

                setStatusMessage(msg)
            return

        if self.performingAction:
            if __debug__:
                trace("%s is currently in use request ignored" %
                      self.clientType)
            return

        self.performingAction = True

        if self.statusMessages:
            msg = constants.MAIL_PROTOCOL_CONNECTION \
                          % {"accountName": self.account.displayName,
                             "serverDNSName": self.account.host}

            setStatusMessage(msg)

        self.factory = self.factoryType(self)

        if self.testing:
            # If in testing mode then do not want to retry connection or
            # wait a long period for a timeout
            self.factory.retries = 0
            self.factory.timeout = constants.TESTING_TIMEOUT

        if self.account.connectionSecurity == 'SSL':
            ssl.connectSSL(self.account.host, self.account.port, self.factory,
                           self.view)
        else:
            ssl.connectTCP(self.account.host, self.account.port, self.factory,
                           self.view)
Esempio n. 3
0
    def _connectToServer(self):
        if __debug__:
            trace("_connectToServer")

        if self.cancel:
            return self._resetClient()

        self.view.refresh()

        #Overidden method
        self._getAccount()

        # The isOnline check is performed in the Twisted thread
        # so pass in a view.
        if not Globals.mailService.isOnline(self.view):
            if self.statusMessages:
                msg = constants.MAIL_PROTOCOL_OFFLINE % \
                              {"accountName": self.account.displayName}

                setStatusMessage(msg)
            return

        if self.performingAction:
            if __debug__:
                trace("%s is currently in use request ignored" % self.clientType)
            return

        self.performingAction = True

        if self.statusMessages:
            msg = constants.MAIL_PROTOCOL_CONNECTION \
                          % {"accountName": self.account.displayName,
                             "serverDNSName": self.account.host}

            setStatusMessage(msg)

        self.factory = self.factoryType(self)

        if self.testing:
            # If in testing mode then do not want to retry connection or
            # wait a long period for a timeout
            self.factory.retries = 0
            self.factory.timeout = constants.TESTING_TIMEOUT

        if self.account.connectionSecurity == 'SSL':
            ssl.connectSSL(self.account.host, self.account.port,
                           self.factory, self.view)
        else:
            ssl.connectTCP(self.account.host, self.account.port,
                           self.factory, self.view)
Esempio n. 4
0
        def callback(password):
            # Note that we cheat with the context factory here (value=1),
            # because ssl.connectSSL does it automatically, and in the
            # case of STARTTLS we override esmtpState_starttls above
            # to supply the correct SSL context.
            factory = smtp.ESMTPSenderFactory(username, password, from_addr,
                                              to_addrs, msg, deferred, retries,
                                              timeout, 1, heloFallback,
                                              authRequired, securityRequired)

            factory.protocol = _TwistedESMTPSender
            factory.testing = testing

            # Convert the Unicode hostname to an str
            # before passing to twisted since twisted uses
            # a repr of the hostname in error messages.
            host = self.account.host.encode("utf-8", "ignore")

            if self.account.connectionSecurity == 'SSL':
                ssl.connectSSL(host, self.account.port, factory, self.view)
            else:
                ssl.connectTCP(host, self.account.port, factory, self.view)