如何使用unicode主题接收入站邮件? [英] How to receive inbound messages with unicode subject?

查看:214
本文介绍了如何使用unicode主题接收入站邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我收到带有Unicode主题的消息时,我收到以下错误:

When I receive message with Unicode subject, I am getting the following error:

'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)

与开发环境相同的问题发生。
有没有办法解决?

The same problem happens with Development environment. Is there any way to fix it?

我在电子邮件标题中看到以下内容:

I see the following in e-mail headers:

Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit


推荐答案

我不得不手动解析电子邮件,因为我没有找到解决这个问题的方法 - http://code.google.com/p/googleappengine/issues/detail?id=8989

请参阅 https://stackoverflow.com/a/16129023/604388 了解我如何做。

这篇关于如何使用unicode主题接收入站邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆