common_utils.py 文件源码

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

项目:metronus 作者: Metronus 项目源码 文件源码
def send_mail(subject, email_template_name, recipients, html_email_template_name,
              context, email_from=DEFAULT_FROM_EMAIL):
    """
    Sends an email to someone
    """
    if 'test' in sys.argv:
        return  # Don't send mails if we are testing to prevent spam

    if context['html']:
        body = loader.render_to_string(email_template_name, context)
    else:
        body = email_template_name

    email_message = EmailMultiAlternatives(subject, body, email_from, recipients)
    if html_email_template_name is not None:
        html_email = loader.render_to_string(html_email_template_name, context)
        email_message.attach_alternative(html_email, 'text/html')

    email_message.send(fail_silently=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号