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)
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)
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
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)
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)
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()
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()
def delete(self, email): EmailAccount.delete(self, email) self._do_action("delete", email)
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)
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)
def delete(self, email): EmailAccount.delete(self, email) self._do_action('delete', email)
def markAsRead(self, email): EmailAccount.markAsRead(self, email) self._do_action('read', email)
) 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)
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
def archive(self, email): EmailAccount.archive(self, email) self._do_action('archive', email) if pref('gmail.markive', False): self.markAsRead(email)
def reportSpam(self, email): EmailAccount.reportSpam(self, email) self._do_action('spam', email)
'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)