如何在Django中发送特定mimetype的邮件?

6 投票
1 回答
908 浏览
提问于 2025-04-15 22:01
MYMESSAGE = "<div>Hello</div><p></p>Hello"
send_mail("testing",MYMESSAGE,"noreply@mydomain.com",['assdf@gmail.com'],fail_silently=False)

不过,这条信息在发送时并没有获取到HTML的mime类型。在我的Outlook里,我看到的是代码...

1 个回答

5

来自文档

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

撰写回答