-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queued Mail Delivery Sets Wrong Charset #41
Comments
@treinhard Thanks for the careful analysis of the problem! |
Experiencing the same issue.
|
lugensa
pushed a commit
to lugensa/repoze.sendmail
that referenced
this issue
Apr 17, 2018
WuShell
added a commit
to WuShell/repoze.sendmail
that referenced
this issue
Feb 20, 2019
Fixes the bug described here: repoze#41 Rationale: get_content_charset() has been there in email.message.Message for a long time now, returning the charset of the body of the Message (which is what we are looking for there). get_charset() has been deprecated for some time now, returns None by default (even if a charset is set in the Content-Type header). There are some other ways to retrieve the charset (get_params(), get_param('charset'), message['Content-Type'].params) but get_content_charset() is the only one that exists through all existing python versions, and it is there even in the new email.message.EmailMessage class.
I've made a PR that fixes this bug, here: #43 @treinhard, @unikmhz I'd be glad if you can give it a try and confirm if it works for you (thanks!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sending an email via pyramid_mailer's
send_to_queue()
and then delivering it with theqp
console script results in an incorrectcharset
ofus-ascii
in theContent-Type
on Python 3.6.2.The initial Message with unicode content is correctly encoded with
iso-8859-1
and the charset is set on the message:The content is written to a file and later (during delivery) parsed in the
QueueProcessor
:Message looks ok (except that msg.get_charset() returns now None).
SMTPMailer.send()
runs this message throughrepoze.sendmail.encoding.cleanup_message()
which replaces the initial message charset ofiso-8859-1
withus-ascii
:The
message.get_charset()
call at https://github.com/repoze/repoze.sendmail/blob/master/repoze/sendmail/encoding.py#L74 returns None (because the charset is None after parsing the message from the file). The fallback on the following lines results in aus-ascii
encoding because the message is already encoded.The result is a message with
Content-Type: text/plain; charset="us-ascii"
containingiso-8859-1
encoded content.The text was updated successfully, but these errors were encountered: