Django HTML邮件

    subject, from_email, to = '来自123的测试邮件', '123@qq.com', '123@hrbust.edu.cn'
    text_content = 'welcome!'
    html_content = '<p>欢迎访问<a href="http://www.baidu.com" target=blank>百度</a>,</p>'
    msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
    msg.attach_alternative(html_content, "text/html")
    msg.send()

发送HTML邮件代码如上所示,需要在setting.py中配置相关信息。

posted @ 2020-06-15 00:14  zju_cxl  阅读(48)  评论(0)    收藏  举报