2
我正在写一个谷歌应用程序引擎的应用程序,处理收到的邮件,这里是我目前使用来处理邮件代码:如何在Python中解码二进制编码的邮件消息?
for content_type, body in email_bodies:
#8bit bug in mail messages - see bug report here
#http://code.google.com/p/googleappengine/issues/detail?id=2383
if body.encoding == '8bit':
body.encoding = '7bit'
#test for html content
if content_type == "text/html":
#parse html result
if content_type == "text/plain":
decoded_msg_body = body.decode()
不过,我只是得到了使用二进制编码方案的消息,当我的程序尝试使用body.decode()处理消息时,我收到一个UnknownEncodingError。该程序应该如何解析二进制内容类型?另外,如何在本地版本的GAE上模拟此消息类型,以便调试和测试它?
我感谢您的帮助, 凯文
如果您使用该消息的“原始”属性,那么它将在GAE上工作,这足够公平。谢谢保罗。 – 2010-10-26 08:57:05
太棒了。我不确定这是多么奇怪的情况下处理,但考虑到这些事情通常如何工作,我认为这可能是一个好机会。 – 2010-10-26 12:39:07