擅长:python、mysql、java
<p>如果您想控制mutlipart电子邮件的不同组件,可以创建一个<code>EmailMultiAlternatives</code>,然后<code>.send()</code>创建的电子邮件。在</p>
<p>Django的exmample来自<a href="https://docs.djangoproject.com/en/1.5/topics/email/#sending-alternative-content-types" rel="nofollow">documentation</a>。在</p>
<pre><code>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")
msg.send()
</code></pre>