anoved / OctoPrint-EmailNotifier

Receive email notifications when OctoPrint jobs are complete. Currently broken. Please fork and fix!
GNU Affero General Public License v3.0
16 stars 35 forks source link

Problem with non-ascii characters in e-mail #30

Open trgtylcnky opened 7 years ago

trgtylcnky commented 7 years ago

Plugin works well but when my e-mail title contains ü, ş, ç etc. it gives this error:

2017-04-07 08:49:20,465 - octoprint.plugins.emailnotifier - ERROR - Email notification error: 'ascii' codec can't encode characters in position 16-18: ordinal not in range(128)
Traceback (most recent call last):
  File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_emailnotifier/__init__.py", line 73, in on_event
    mailer.send(to=emails, subject=title, contents=content, validate_email=False)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/yagmail/yagmail.py", line 107, in send
    msg = self._prepare_message(addresses, subject, contents, attachments, headers)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/yagmail/yagmail.py", line 230, in _prepare_message
    has_included_images, content_objects = self._prepare_contents(contents)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/yagmail/yagmail.py", line 298, in _prepare_contents
    content_object = self._get_mime_object(content)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/yagmail/yagmail.py", line 368, in _get_mime_object
    content_name = os.path.basename(str(content_string))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 16-18: ordinal not in range(128)
anoved commented 7 years ago

Thanks for the feedback. I apologize for this problem as internationalization is important to me. Unfortunately I have not been able to maintain this plug-in recently, but figuring this out will be a top priority when and if I do get a chance to work on it.

anoved commented 7 years ago

It looks like this may be a known issue with yagmail that has been fixed: https://github.com/kootenpv/yagmail/pull/32

If possible, try updating your OctoPrint installation to use the current distribution of yagmail with:

~/oprint/bin/pip install -U yagmail

I am using the current yagmail (0.6.161) and can't reproduce this problem - characters such as üşç come through in the email title OK. Let me know if updating yagmail helps you as well or not.