邮件实例在Google应用引擎邮件接收中没有属性“已读”

时间:2009-12-07 18:45:26

标签: python google-app-engine email

接收处理程序中的代码

class LogSenderHandler(InboundMailHandler):
   def receive(self, mail_message):
    logging.info("Received a message from: " + mail_message.sender)
    #logging.info("Received a message from: " + mail_message.attachments)
    logging.info("Received a message from: " + mail_message.date)
    logging.info("Received a message from: " + mail_message.subject)
    report = DocFile()
    report.doc_name = mail_message.subject
    if mail_message.attachments is not None:
        report.doc_file = mail_message.attachments
    else:
        report.doc_file = mail_message.bodies(content_type='text/plain')
    report.put()

application = webapp.WSGIApplication([LogSenderHandler.mapping()], debug=True)        

def main():
run_wsgi_app(application)
if __name__ == "__main__":
 main()
url.py中的代码

inbound_services:
- mail

handlers:
- url: /_ah/mail/.+ 
script: handle_incoming_email.py
尝试从http://localhost:8080/_ah/admin/inboundmail

发送简单电子邮件时出现

错误

Message send failure

    Traceback (most recent call last):
  File "F:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 509, in __call__
    handler.post(*groups)
  File "F:\Program Files\Google\google_appengine\google\appengine\ext\webapp\mail_handlers.py", line 58, in post
    self.receive(mail.InboundEmailMessage(self.request.body))
  File "F:\Program Files\Google\google_appengine\google\appengine\api\mail.py", line 547, in __init__
    self.update_from_mime_message(mime_message)
  File "F:\Program Files\Google\google_appengine\google\appengine\api\mail.py", line 1081, in update_from_mime_message
    mime_message = _parse_mime_message(mime_message)
  File "F:\Program Files\Google\google_appengine\google\appengine\api\mail.py", line 232, in _parse_mime_message
    return email.message_from_file(mime_message)
  File "F:\Python25\lib\email\__init__.py", line 66, in message_from_file
    return Parser(*args, **kws).parse(fp)
  File "F:\Python25\lib\email\parser.py", line 68, in parse
    data = fp.read(8192)
  AttributeError: Message instance has no attribute 'read'

EDIT 此错误仅在本地计算机上出现,而不在应用程序引擎

1 个答案:

答案 0 :(得分:0)

您是否拥有最新版本的API?传入邮件功能需要是1.2.6或最大。

后来我在谷歌小组中看到了我引用约书亚史密斯的“解决方案”

“我发现您需要在

之前重新启动本地开发环境

进行任何入站邮件测试。否则,你会得到读错误“

因此,每次更改代码时,必须重新启动服务器,即使只添加空格(严重)