def send_to_recipient(self, use_https, domain):
stripped_email = strip_email(self.recipient_email)
if BlacklistedEmail.objects.filter(stripped_email=stripped_email).count():
return
blacklist_digest = salted_hmac(BLACKLIST_HMAC_SALT, self.recipient_email).hexdigest()
blacklist_url = reverse('messaging:blacklist_email', kwargs={'email': self.recipient_email, 'digest': blacklist_digest})
self.recipient_email_token = readable_random_token(alphanumeric=True)
self.status = Message.STATUS.sent
context = {
'message': self,
'protocol': 'https' if use_https else 'http',
'domain': domain,
'recipient': self.recipient_email,
'blacklist_url': blacklist_url,
}
subject = render_to_string('messaging/recipient_subject.txt', context)
subject = ' '.join(subject.splitlines())
body_txt = render_to_string('messaging/recipient_mail.txt', context)
body_html = render_to_string('messaging/recipient_mail.html', context)
send_html_mail(subject, body_txt, body_html, self.recipient_email)
self.save()
评论列表
文章目录