Python Emailing Multipart with body content

前端 未结 1 390
渐次进展
渐次进展 2021-01-21 22:43

I can\'t send an e-mail in python with a body as a multipart email. Everything I\'ve tried has resulted in all of the content as attachments, and I can\'t get the text or html t

相关标签:
1条回答
  • 2021-01-21 23:11

    You need to specify that the parts are alternatives of one another, e.g. the multipart/alternative mime type:

    msg = MIMEMultipart('alternative')
    

    The default is mixed; see the email library examples.

    Note that to create an email with both attachments and an alternative (HTML / CSS) option you'll need to have a top-level multipart/related container that contains the alternative parts as the first entry.

    0 讨论(0)
提交回复
热议问题