def send_access_token_notifcation(token):
plaintext = get_template('email-access-token-granted.txt')
htmly = get_template('email-access-token-granted.html')
context = {"APPLICATION_TITLE": settings.APPLICATION_TITLE,
"APP_NAME": token.application.name,
"HOSTNAME": get_hostname()
}
subject = '[%s] You just granted access to %s' % (settings.APPLICATION_TITLE,
token.application.name)
from_email = settings.DEFAULT_FROM_EMAIL
to_email = token.user.email
text_content = plaintext.render(context)
html_content = htmly.render(context)
msg = EmailMultiAlternatives(
subject, text_content, from_email, [
to_email, ])
msg.attach_alternative(html_content, "text/html")
msg.send()
评论列表
文章目录