This causes both the email_to_dict and dict_to_email function to fail. email_to_dict fails because the attachment returned by Django is a string and not bytes, and dict_to_email fails because Django itself complains if you try to send an email with a text/* mimetype and a binary content.
This causes the a bytes-like object is required, not 'str' error to be raised at this line
I added workarounds to both functions and a regression test.
For emails attachments contains a mimetype starting with
text/
, Django expects the content to be a string. This behavior is documented in here:https://docs.djangoproject.com/en/2.0/topics/email/#emailmessage-objects
This causes both the
email_to_dict
anddict_to_email
function to fail.email_to_dict
fails because the attachment returned by Django is a string and not bytes, anddict_to_email
fails because Django itself complains if you try to send an email with a text/* mimetype and a binary content.This causes the
a bytes-like object is required, not 'str'
error to be raised at this lineI added workarounds to both functions and a regression test.