如何使用某种mimetype在Django中发送电子邮件?

时间:2010-04-26 09:56:17

标签: python django smtp email mime

MYMESSAGE = "<div>Hello</div><p></p>Hello"
send_mail("testing",MYMESSAGE,"noreply@mydomain.com",['assdf@gmail.com'],fail_silently=False)

但是,此消息在发送时不会获取HTML mime类型。在我的展望中,我看到了代码......

1 个答案:

答案 0 :(得分:5)

来自the docs

msg = EmailMessage(subject, html_content, from_email, [to])
msg.content_subtype = "html"  # Main content is now text/html
msg.send()

您只能更改它看起来的mimetype的子类型。所以它永远是

"text/%s" % msg.content_subtype