Skip to content
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

proper UTF-8 encoding of email content #585

Merged
merged 1 commit into from Nov 30, 2018
Merged

proper UTF-8 encoding of email content #585

merged 1 commit into from Nov 30, 2018

Conversation

@thorli
Copy link
Contributor

@thorli thorli commented Nov 30, 2018

Hello,

I just ran into issues with the Email.py script that postprocessing failed because of errors like this:

Wed Nov 28 2018 01:20:01 DETAIL EMail: Script successfully started
Wed Nov 28 2018 01:20:01 INFO EMail: Traceback (most recent call last):
Wed Nov 28 2018 01:20:01 INFO EMail: File "/downloads/scripts/EMail.py", line 245, in
Wed Nov 28 2018 01:20:01 INFO EMail: msg = MIMEText(text)
Wed Nov 28 2018 01:20:01 INFO EMail: File "/usr/lib/python2.7/email/mime/text.py", line 30, in init
Wed Nov 28 2018 01:20:01 INFO EMail: self.set_payload(_text, _charset)
Wed Nov 28 2018 01:20:01 INFO EMail: File "/usr/lib/python2.7/email/message.py", line 226, in set_payload
Wed Nov 28 2018 01:20:01 INFO EMail: self.set_charset(charset)
Wed Nov 28 2018 01:20:01 INFO EMail: File "/usr/lib/python2.7/email/message.py", line 262, in set_charset
Wed Nov 28 2018 01:20:01 INFO EMail: self._payload = self._payload.encode(charset.output_charset)
Wed Nov 28 2018 01:20:01 INFO EMail: UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 27060: ordinal not in range(128)

I identified german umlauts and some other non ascii characters beeing the cause of these errors. I did some research and found out to avoid errors like this it's best practice to perform a proper encoding of the email body.

In my own environment (nzbget is running in docker on Synology NAS with DSM 6.2) where python sys.getdefaultencoding() is "ascii", everything is working fine again.

Cheers,
Jürgen

Updated script so the email content is encoded properly in UTF-8 to avoid "UnicodeEncodeErrors" when non ascii characters are used like german Umlauts etc.
@hugbug hugbug merged commit da3425a into nzbget:develop Nov 30, 2018
1 check was pending
1 check was pending
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@hugbug
Copy link
Member

@hugbug hugbug commented Nov 30, 2018

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants