在我的应用中,每当我尝试接收应用程序的电子邮件并向receive()方法发送请求时,我都会收到错误 405 Method Not Allowed 。
通过id string@appid.appspotmail.com发送电子邮件正常,但是收到此ID的电子邮件会导致此错误。
我像这样配置了我的应用
application: abc
version: 1
runtime: python27
api_version: 1
threadsafe : false
inbound_services:
- mail
handlers:
- url: /_ah/mail/.+
script: incoming_mail.py
login: admin
- url: /
script: abc.py
import email
import logging
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
class LogSenderHandler(InboundMailHandler):
def receive(self,email):
logging.info("Received a message from: %s" % email.sender)
app = webapp.WSGIApplication([LogSenderHandler.mapping()], debug=True)
def main():
run_wsgi_app(app)
if __name__ == "__main__":
main()
每当我浏览此网址http://appid.appspot.com/_ah/mail/string@appid.appspotmail.com
时我收到错误 405方法不允许。
完全陷入困境。提前感谢您提供的任何帮助!
答案 0 :(得分:2)
GAE不会存储您收到的邮件。您需要存储它并创建自己的代码来管理它。他们提到" / _ ah / mail / address"解释如何在app.yaml中处理它。如果向下滚动,可以看到如何处理多个不同的处理程序。
您不允许使用" 405方法此资源不允许使用方法GET。 "因为您的代码中没有 获取 处理程序。
就我个人而言,我会将电子邮件存储在Ancestor-Key数据存储区(父母是其发送给的人)中,并有另一个脚本句柄管理它(即查看,回复,删除)。