我一直在阅读堆栈溢出,但到目前为止,我还没有找到适合我的解决方案。我希望能够处理收到的电子邮件到我的应用程序,并最终使用附件,但我遇到了一个问题。
的app.yaml
$ jq --version
jq version 1.3
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename: trusty
handle_incoming_email.py
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
成功启动dev_appserver后: 从http://localhost:8000/mail我尝试发送电子邮件至info@egg-api.appspotmail.com,但我得到:
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)
当我访问http://localhost:8080/_ah/login时,我不知道我应该输入什么。
感谢您的帮助
答案 0 :(得分:2)
移动通用处理程序
- url: .*
到特定处理程序之后
- url: /_ah/mail/info@egg-api.appspotmail.com
即:
- 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
否则,首先应用常规URL规则,结果为404。