当我收到带有Unicode主题的消息时,我收到以下错误:
'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 716, in __call__
handler.post(*groups)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/mail_handlers.py", line 69, in post
self.receive(mail.InboundEmailMessage(self.request.body))
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/mail.py", line 742, in __init__
self.update_from_mime_message(mime_message)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/mail.py", line 1304, in update_from_mime_message
super(InboundEmailMessage, self).update_from_mime_message(mime_message)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/mail.py", line 1213, in update_from_mime_message
super(EmailMessage, self).update_from_mime_message(mime_message)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/mail.py", line 1093, in update_from_mime_message
subject = _decode_and_join_header(mime_message['subject'], separator=u'')
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/mail.py", line 558, in _decode_and_join_header
for s, c in email.header.decode_header(header))
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/mail.py", line 558, in <genexpr>
for s, c in email.header.decode_header(header))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
开发环境也会出现同样的问题。 有没有办法解决它?
我在电子邮件标题中看到以下内容:
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
答案 0 :(得分:0)
我必须手动解析电子邮件,因为我找不到解决此问题的方法 - http://code.google.com/p/googleappengine/issues/detail?id=8989
请参阅https://stackoverflow.com/a/16129023/604388了解我是如何做到的。