#27007: Allow bytes objects as text/* attachments
--------------------------------------+--------------------
Reporter: Feuermurmel | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Mail) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
I've noticed that that `attach()` from `django.core.mail.EmailMessage`
allows a `bytes` object to be passed as content even when the MIME type is
set to `text/plain`. `SafeMIMEText` will then try to decode the text in
the bytes object as UTF-8, which is necessary because the MIME
specifications require `text/*` parts to be decodable with the encoding
specified in the //Content-Type// header. But decoding the `bytes` object
will fail if the bytes object does not contain valid UTF-8 encoded text.
OTOH, `attach_file()` will in that case first try to decode the file's
content but fall back on treating the attachment as binary, setting the
Content-Type to `application/octet-stream`.
I think the fallback provided by `attach_file()` is useful and I would
like to extend `attach()` to that same behavior.
--
Ticket URL: <https://code.djangoproject.com/ticket/27007>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.e6ebe57a8ba93d0c0c97d500a990122f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.