码迷,mamicode.com
首页 > Web开发 > 详细

Django 发送html邮件

时间:2016-10-10 01:34:12      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

转载于: 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, [收件人列表]):

Django 发送html邮件

标签:

原文地址:http://www.cnblogs.com/haoshine/p/5944392.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!