How do I send attachments using SMTP?

后端 未结 6 891
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 01:55

I want to write a program that sends email using Python\'s smtplib. I searched through the document and the RFCs, but couldn\'t find anything related to attachments. Thus,

6条回答
  •  遥遥无期
    2020-12-01 02:14

    Well, attachments are not treated in any special ways, they are "just" leaves of the Message-object tree. You can find the answers to any questions regarding MIME-compliant mesasges in this section of the documentation on the email python package.

    In general, any kind of attachment (read: raw binary data) can be represented by using base64 (or similar) Content-Transfer-Encoding.

提交回复
热议问题