emails.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号