本文整理汇总了Python中mailer.Mailer.authenticate方法的典型用法代码示例。如果您正苦于以下问题:Python Mailer.authenticate方法的具体用法?Python Mailer.authenticate怎么用?Python Mailer.authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailer.Mailer
的用法示例。
在下文中一共展示了Mailer.authenticate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Schedueler
# 需要导入模块: from mailer import Mailer [as 别名]
# 或者: from mailer.Mailer import authenticate [as 别名]
class Schedueler(object):
def __init__(self, queue = None):
self._mailer = Mailer()
self._queue = queue or []
self.schedueled_entries_that_were_sent = []
@property
def queue(self):
return self._queue
def run(self, now = datetime.datetime.now()):
for schedueled_mail in self.mails_to_be_sent_now(now = now):
index = self._queue.index(schedueled_mail)
schedueled_entry = self._queue.pop(index)
self.send(schedueled_entry);
def mails_to_be_sent_now(self, now = datetime.datetime.now()):
return filter(lambda schedueled_entry: schedueled_entry.when < now and schedueled_entry.sent == False, self._queue)
def mark_as_sent(self, schedueled_entry):
schedueled_entry.sent = True
self.schedueled_entries_that_were_sent.append(schedueled_entry)
def connect(self):
self._mailer.connect()
self._mailer.authenticate()
def disconnect(self):
self._mailer.disconnect()
def send(self, schedueled_entry):
try:
self._mailer.send(schedueled_entry.mail)
self.mark_as_sent(schedueled_entry)
except smtplib.SMTPException:
self._queue.append(schedueled_entry)