#6918 closed (fixed)
Cannot set encoding of mail headers, only of message body
Reported by: | Owned by: | Sung-jin Hong | |
---|---|---|---|
Component: | Core (Mail) | Version: | dev |
Severity: | Keywords: | encoding mail headers | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In http://code.djangoproject.com/changeset/5553 support for encoding of mail body was added. I think also mail headers should be encoded with the same encoding, there is no way of setting mail headers encoding other than setting DEFAULT_CHARSET encoding right now - and for mail attachments as well.
For me it is a problem, because I need to set the encoding to other than utf-8, but I cannot do it for the mail subject.
Attachments (3)
Change History (12)
comment:1 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
by , 16 years ago
Attachment: | mail_patch.diff added |
---|
comment:2 by , 16 years ago
Has patch: | set |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Marking ready for checkin. Can someone review my patch? Thanks.
comment:3 by , 16 years ago
Triage Stage: | Ready for checkin → Design decision needed |
---|
It's not immediately clear this is a good idea. If you're passing text to Django it should be UTF-8 or Unicode as a rule. We allow different encodings in mail bodies because that allows slightly reduced data volume for East Asian languages. There's not really such a saving for mail headers.
Moving to "design decision needed", because this needs some thought (also patches requiring review are not "ready for checkin").
comment:4 by , 16 years ago
It's not a problem about size. There are even some mail clients in the world that does not accept utf-8 title headers. (Asian countries old e-mail clients often do that) And apart from that, it's the user's choice to select different header encoding. Not ours. And we should give as many choices possible to user as possible.
comment:5 by , 16 years ago
As serialx mentioned, the problem was not with the size of the message but with an email client - if I remember correctly it was interia.pl web server, which did not recognize UTF-8 encoding. So I was forced to use ISO-8859-2 encoding which is properly understood by all polish mail clients. And I was forced to use it not only in the body of the message but also in the Subject header.
by , 16 years ago
Attachment: | mail-header-encoding.diff added |
---|
New improved working patch. (It actually changes the encoding of the mail header)
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 by , 15 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Test is causing a failure on the buildbots: http://buildbot.djangoproject.com/waterfall
Near as I can tell the only significant difference in the output is that the test is expecting the multipart message to start:
Content-Type: multipart/alternative; boundary=
But instead is getting:
Content-Type: multipart/alternative;\n\tboundary=
Buildbots are ubutntu, running Pythons 2.4, 2.5, 2.6. Oddly enough the test worked on my Ubuntu (older) using Python 2.5. Any clue what's causing this? I suppose we can just change the test to not care whether multipart-alternative;
is followed by \n\t
or not, since what we are really testing for is that the correct encoding has been used in the content....
comment:8 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Since the send_mail function API is frozen, adding another 'encoding' parameter may not be added. I'm submitting a patch to resolve this issue with two possible ways:
It _IS_ currently possible to specify the encoding of the mail using the EmailMessage like..
But it does not kill to support encoding parameter in the send_mail and the constructor.
This patch enables..
Or even