def send_activation_key_via_email(user, signup_key):
"""Do not call this directly. Instead use create_signup_key in utils."""
plaintext = get_template('email-activate.txt')
htmly = get_template('email-activate.html')
subject = '[%s] Verify your email to complete account signup' % (
settings.APPLICATION_TITLE)
from_email = settings.DEFAULT_FROM_EMAIL
to_email = user.email
activation_link = '%s%s' % (get_hostname(),
reverse('activation_verify',
args=(signup_key,)))
context = {"APPLICATION_TITLE": settings.APPLICATION_TITLE,
"FIRST_NAME": user.first_name,
"LAST_NAME": user.last_name,
"ACTIVATION_LINK": activation_link}
subject = '[%s] Verify your email to complete your account setup.' % (
settings.APPLICATION_TITLE)
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()
评论列表
文章目录