您可以在您的
msg.alternatives
这是一个元组列表。
请参阅下面的用法
from django.core.mail import EmailMultiAlternatives
subject, from_email, to = 'hello', 'from@example.com', 'to@example.com'
text_content = 'This is an important message.'
html_content = '<p>This is an <strong>important</strong> message.</p>'
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
# This prints [('<p>This is an <strong>important</strong> message.</p>', 'text/html')]
print(msg.alternatives)
# Prints ('<p>This is an <strong>important</strong> message.</p>', 'text/html')
print(msg.alternatives[0])
# Prints '<p>This is an <strong>important</strong> message.</p>'
print(msg.alternatives[0][0])
msg.send()