emails.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:bluebutton-web-server 作者: CMSgov 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号