Exemplo n.º 1
0
 def __init__(self, **options):
     d = self.default
     self.smtp_server       = options.get('smtp_server', d('smtp_server'))
     self.smtp_require_ssl  = options.get('smtp_require_ssl', d('smtp_require_ssl'))
     self.smtp_port         = options.get('smtp_port', d('smtp_port'))
     self.smtp_username     = options.get('smtp_username', d('smtp_username'))
     self._email_address    = options.get('email_address', d('email_address'))
     self._encrypted_smtppw = profile.crypt_pw(options.get('smtp_password', d('smtp_password')))
     self._encrypted_pw     = options.pop('password')
     EmailAccount.__init__(self, password=self.password, **options)
Exemplo n.º 2
0
 def __init__(self, **options):
     d = self.default
     self.smtp_server = options.get("smtp_server", d("smtp_server"))
     self.smtp_require_ssl = options.get("smtp_require_ssl", d("smtp_require_ssl"))
     self.smtp_port = options.get("smtp_port", d("smtp_port"))
     self.smtp_username = options.get("smtp_username", d("smtp_username"))
     self._email_address = options.get("email_address", d("email_address"))
     self._encrypted_smtppw = profile.crypt_pw(options.get("smtp_password", d("smtp_password")))
     self._encrypted_pw = options.pop("password")
     EmailAccount.__init__(self, password=self.password, **options)
Exemplo n.º 3
0
 def _get_options(self):
     opts = EmailAccount._get_options(self)
     opts.update(
         dict(
             (a, getattr(self, a))
             for a in "smtp_server smtp_port smtp_require_ssl smtp_username email_address".split()
         )
     )
     return opts
Exemplo n.º 4
0
    def update_info(self, **info):
        if not self.isflagged(NETWORK_FLAG):
            if "smtp_password" in info:
                self._encrypted_smtppw = profile.crypt_pw(info.pop("smtp_password"))

                if "password" in info:
                    self._encrypted_pw = info["password"]

            if "_encrypted_pw" in info and "_encrypted_smtppw" in info:
                self._encrypted_pw = info.pop("_encrypted_pw")
                self._encrypted_smtppw = info.pop("_encrypted_smtppw")

            info["password"] = self._glue_pw(self._encrypted_pw, self._encrypted_smtppw)
        else:
            self.password = info.pop("password")

        log.info("smtp update_info: %r", info)
        EmailAccount.update_info(self, **info)
Exemplo n.º 5
0
    def update_info(self, **info):
        if not self.isflagged(NETWORK_FLAG):
            if 'smtp_password' in info:
                self._encrypted_smtppw = profile.crypt_pw(info.pop('smtp_password'))

                if 'password' in info:
                    self._encrypted_pw = info['password']

            if '_encrypted_pw' in info and '_encrypted_smtppw' in info:
                self._encrypted_pw = info.pop('_encrypted_pw')
                self._encrypted_smtppw = info.pop('_encrypted_smtppw')

            info['password'] = self._glue_pw(self._encrypted_pw, self._encrypted_smtppw)
        else:
            self.password = info.pop('password')

        log.info("smtp update_info: %r", info)
        EmailAccount.update_info(self, **info)
Exemplo n.º 6
0
    def __init__(self, **k):
        EmailAccount.__init__(self, **k)
        self.internal_token = ""
        self.external_token = ""
        self.token_lock = threading.RLock()
        self.datatoken = ""
        self.updated_emails = None
        self.updated_count = None
        self.update_lock = Lock()
        self.emailaddress = EmailAddress(self.name, "gmail.com")
        self._hosted = None
        self._multi = None

        if self.emailaddress.domain in ("gmail.com", "googlemail.com"):
            self.baseMailUrl = "://mail.google.com/mail/"
        else:
            self.baseMailUrl = "://mail.google.com/a/" + self.emailaddress.domain + "/"

        self.browser_http = "https"

        self.init_jar()
Exemplo n.º 7
0
    def __init__(self, **k):
        EmailAccount.__init__(self, **k)
        self.internal_token = ''
        self.external_token = ''
        self.token_lock = threading.RLock()
        self.datatoken = ''
        self.updated_emails = None
        self.updated_count = None
        self.update_lock = Lock()
        self.emailaddress = EmailAddress(self.name, 'gmail.com')
        self._hosted = None
        self._multi = None

        if self.emailaddress.domain in ('gmail.com', 'googlemail.com'):
            self.baseMailUrl = '://mail.google.com/mail/'
        else:
            self.baseMailUrl = '://mail.google.com/a/' + self.emailaddress.domain + '/'

        self.browser_http = 'https'

        self.init_jar()
Exemplo n.º 8
0
    def __init__(self, **k):
        EmailAccount.__init__(self, **k)
        self.internal_token = ''
        self.external_token = ''
        self.token_lock = threading.RLock()
        self.datatoken = ''
        self.updated_emails = None
        self.updated_count = None
        self.update_lock = Lock()
        self.emailaddress = EmailAddress(self.name, 'gmail.com')
        self._hosted = None
        self._multi = None

        if self.emailaddress.domain in ('gmail.com', 'googlemail.com'):
            self.baseMailUrl = '://mail.google.com/mail/'
        else:
            self.baseMailUrl = '://mail.google.com/a/' + self.emailaddress.domain + '/'

        self.browser_http = 'https'

        self.init_jar()
Exemplo n.º 9
0
 def delete(self, email):
     EmailAccount.delete(self, email)
     self._do_action("delete", email)
Exemplo n.º 10
0
 def update(self):
     log.info("update at %s", time.ctime(time.time()))
     EmailAccount.update(self)
     self.real_update(success=self.finish_update, error=self.on_error)
Exemplo n.º 11
0
 def update(self):
     log.info("update at %s", time.ctime(time.time()))
     EmailAccount.update(self)
     self.real_update(success = self.finish_update, error=self.on_error)
Exemplo n.º 12
0
 def delete(self, email):
     EmailAccount.delete(self, email)
     self._do_action('delete', email)
Exemplo n.º 13
0
 def markAsRead(self, email):
     EmailAccount.markAsRead(self, email)
     self._do_action('read', email)
Exemplo n.º 14
0
        )
        return opts

    @classmethod
    def from_net(cls, info):
        password = info.password  # IS BOTH, NEEDS TO BE ONE
        try:
            encrypted_pw, encrypted_smtppw = cls._unglue_pw(password)
        except Exception, e:
            traceback.print_exc()
            assert SMTP_UPGRADING
            encrypted_pw = password
            encrypted_smtppw = u""
        info.password = encrypted_pw
        smtppw = profile.plain_pw(encrypted_smtppw)
        return EmailAccount.from_net(info, smtp_password=smtppw)

    @threaded
    def send_email(self, to="", subject="", body="", cc="", bcc=""):
        un = self.smtp_username or self.username
        f = self.from_name
        password = self._decrypted_smtppw() or (self._decryptedpw() if not self.smtp_username else "")
        srv = self.smtp_server
        if srv in ("smtp.aol.com", "smtp.aim.com"):
            if un.endswith("aol.com") or un.endswith("aim.com"):
                f = un
            else:
                f = un + u"@aol.com"
        s = SMTPsender(un, password, srv, from_name=f, use_tls=self.smtp_require_ssl)
        s.send_email(to=to, subject=subject, body=body, cc=cc, bcc=bcc)
Exemplo n.º 15
0
 def _get_options(self):
     opts = EmailAccount._get_options(self)
     opts.update(dict((a, getattr(self, a)) for a in
         'smtp_server smtp_port smtp_require_ssl smtp_username email_address'.split()))
     return opts
Exemplo n.º 16
0
 def markAsRead(self, email):
     EmailAccount.markAsRead(self, email)
     self._do_action('read', email)
Exemplo n.º 17
0
    def archive(self, email):
        EmailAccount.archive(self, email)
        self._do_action('archive', email)

        if pref('gmail.markive', False):
            self.markAsRead(email)
Exemplo n.º 18
0
    def archive(self, email):
        EmailAccount.archive(self, email)
        self._do_action('archive', email)

        if pref('gmail.markive', False):
            self.markAsRead(email)
Exemplo n.º 19
0
 def reportSpam(self, email):
     EmailAccount.reportSpam(self, email)
     self._do_action('spam', email)
Exemplo n.º 20
0
 def delete(self, email):
     EmailAccount.delete(self, email)
     self._do_action('delete', email)
Exemplo n.º 21
0
 def reportSpam(self, email):
     EmailAccount.reportSpam(self, email)
     self._do_action('spam', email)
Exemplo n.º 22
0
            'smtp_server smtp_port smtp_require_ssl smtp_username email_address'.split()))
        return opts

    @classmethod
    def from_net(cls, info):
        password = info.password #IS BOTH, NEEDS TO BE ONE
        try:
            encrypted_pw, encrypted_smtppw = cls._unglue_pw(password)
        except Exception, e:
            traceback.print_exc()
            assert SMTP_UPGRADING
            encrypted_pw = password
            encrypted_smtppw = u''
        info.password = encrypted_pw
        smtppw = profile.plain_pw(encrypted_smtppw)
        return EmailAccount.from_net(info, smtp_password=smtppw)

    @threaded
    def send_email(self, to='', subject='', body='', cc='', bcc=''):
        un  = self.smtp_username or self.username
        f   = self.from_name
        password   = self._decrypted_smtppw() or (self._decryptedpw() if not self.smtp_username else '')
        srv = self.smtp_server
        if srv in ("smtp.aol.com", "smtp.aim.com"):
            if un.endswith('aol.com') or un.endswith('aim.com'):
                f = un
            else:
                f = un + u'@aol.com'
        s = SMTPsender(un, password, srv, from_name=f, use_tls=self.smtp_require_ssl)
        s.send_email(to=to, subject=subject, body=body, cc=cc, bcc=bcc)