﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27007	Handle non-UTF-8 bytes objects for text/* attachments	Michael Schwarz	nobody	"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."	Cleanup/optimization	closed	Core (Mail)	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
