def to_mail(self, email, locale=None, context=None, skip_queue=False):
with override(locale):
context = context or dict()
try:
subject = str(self.subject).format(**context)
text = str(self.text).format(**context)
except KeyError as e:
raise SendMailException(f'Experienced KeyError when rendering Text: {str(e)}')
mail = EMail(
to=email,
reply_to=self.reply_to,
bcc=self.bcc,
subject=subject,
text=text,
)
if skip_queue:
mail.send()
else:
mail.save()
return mail
评论列表
文章目录