gpt4 book ai didi

python - 消息实例在 Google 应用引擎邮件接收中没有属性 'read'

转载 作者:太空宇宙 更新时间:2023-11-04 06:39:50 24 4
gpt4 key购买 nike

接收处理程序中的代码

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'

编辑此错误仅出现在本地机器上,而不出现在应用引擎上

最佳答案

您有最新版本的 API 吗?收邮件功能需要1.2.6以上版本。

后来我在 google groups 看到我引用 Joshua Smith 的“解决方案”

"我发现你之前需要重启本地开发环境

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

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

关于python - 消息实例在 Google 应用引擎邮件接收中没有属性 'read',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1862041/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com