1

for an activity with fastapi, I am preparing a Response object with the content of a email.mime.multipart MIMEMultipart object. Adhering to the standards (RFC), a MIMEMultipart response uses CRLF line endings (policy=HTTP). However, the binary attachment I am adding with MIMEApplication() and multipart.attach() in that case gets corrupted since all bytes corresponding to newlines (LF) are replaces with CRLF.

Am I doing something wrong or is this a bug that needs to be fixed?

What I would like to achieve is building a RFC-compliant MIMEMultipart payload in which the subparts do not get altered (in case of application/octet-stream).

Thanks,

Sophonet

Sophonet
  • 11
  • 1
  • MIMEApplication is a subclass of MIMENonMultipart which explicitly exists to prevent the use of attach() https://docs.python.org/2.7/library/email.mime.html#email.mime.application.MIMEApplication – Amos Baker Dec 22 '21 at 15:12
  • Well I am adding the MIMEApplication to MIMEMultipart by calling multipart.attach(), like it can be found on various code snippets on the web, e.g. [here](https://stackoverflow.com/questions/3362600/how-to-send-email-attachments) – Sophonet Dec 23 '21 at 09:36

0 Answers0