zoukankan      html  css  js  c++  java
  • Django 发送html邮件

    转载于: http://blog.sina.com.cn/s/blog_76e94d2101011bxd.html
     
    django中发送html邮件:
     
    #mailer.py
     
    # -*- coding: utf-8 -*-
    from django.core.mail import EmailMessage
    from django.template import loader
     
    from settings import EMAIL_HOST_USER   #项目配置邮件地址,请参考发送普通邮件部分
     
    def send_html_mail(subject, html_content, recipient_list):
        msg = EmailMessage(subject, html_content, EMAIL_HOST_USER, recipient_list)
        msg.content_subtype = "html" # Main content is now text/html
        msg.send()
     
    subject = u'邮件主题'
    html_content = loader.render_to_string(
                         template_path,               #需要渲染的html模板
                         {
                            ‘paramters’:paramters    #参数
                         }
                   )
     
    send_html_mail(subject, html_content, [收件人列表]):
  • 相关阅读:
    UI Automator Viewer工具的使用
    SQL数据库面试50题(转载)
    Python +selenium+pycharm(Windows)
    python安装及环境变量配置(Windows)
    JDK的安装与环境变量配置
    shell参数
    文件添加行号
    CentOS 7修改UTC为CST
    shell控制超时
    fio笔记
  • 原文地址:https://www.cnblogs.com/haoshine/p/5944392.html
Copyright © 2011-2022 走看看