Skip to content Skip to sidebar Skip to footer

Smtp Send Email And Why One Attachment Can Have Two Content-type?

I'm trying use smtp to send email with attachment.And when I get raw email,there are two content-type for one attachment. How can I just get one content-type?And the two type impac

Solution 1:

If you look at the documentation for the MIMEApplication class, you should be passing the mime type in the constructor, not adding it as a separate header.

part = MIMEApplication(open("file.pdf", 'rb').read(), 'pdf')
filename="file.pdf"
part.add_header('Content-Disposition', 'attachment', filename=filename)

Post a Comment for "Smtp Send Email And Why One Attachment Can Have Two Content-type?"