“POST /_ah/mail/.+"返回404 [英] "POST /_ah/mail/.+" returning 404
问题描述
我一直在阅读堆栈溢出问题,但到目前为止,我还没有找到适合我的解决方案。我希望能够处理收到的电子邮件到我的应用程序,并最终处理附件,但我面临一个问题。
I have been reading on stack overflow and but so far I have not found a solution that would work for me. I want to be able to handle incoming email to my app and eventually work with attachments but I am facing an issue.
app.yaml
application: egg-api
runtime: python27
api_version: 1
threadsafe: yes
builtins:
- remote_api: on
# Activate email receiving
inbound_services:
- mail
# This handler tells app engine how to route requests to a WSGI application.
- url: .* # This regex directs all routes to main.app
script: main.app
- url: /_ah/mail/info@egg-api.appspotmail.com # route everything to handle incoming
script: handle_incoming_email.app
login: admin
# Third party libraries
libraries:
- name: jinja2
version: latest
- name: lxml
version: latest
- name: webapp2
version: latest
- name: MySQLdb
version: latest
handle_incoming_email.py
handle_incoming_email.py
import logging
import webapp2
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.api import mail
class LogSenderHandler(InboundMailHandler):
def receive(self, mail_message):
logging.info("Received a message from: " + mail_message.sender)
app = webapp2.WSGIApplication([LogSenderHandler.mapping()], debug=True)
成功启动dev_appserver后:
从 http:// localhost:8000 / mail 我尝试发送一封电子邮件到info@egg-api.appspotmail.com,但我得到:
After starting dev_appserver successfully: From http://localhost:8000/mail I try to send an email to info@egg-api.appspotmail.com but I get:
INFO 2016-04-06 21:31:26,549 module.py:787] default: "POST /_ah/mail/info%40egg-api.appspotmail.com HTTP/1.1" 404 106
访问 http:// localhost: 8080 / _ah / login 我不知道我应该输入什么。
When I visit http://localhost:8080/_ah/login I have no clue what I am supposed to enter.
感谢您的帮助
推荐答案
移动常规处理程序
- url: .*
到特定处理程序之后
to after the specific handler
- url: /_ah/mail/info@egg-api.appspotmail.com
即:
ie:
- url: /_ah/mail/info@egg-api.appspotmail.com # route everything to handle incoming
script: handle_incoming_email.app
login: admin
- url: .* # This regex directs all routes to main.app
script: main.app
否则,首先应用通用网址规则,结果为404。
Otherwise the general URL rule is applied first, resulting in a 404.
这篇关于“POST /_ah/mail/.+"返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!