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

TIM*_*MEX 6 python email django mime smtp

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

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

Den*_*gan 5

来自文档:

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

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

"text/%s" % msg.content_subtype