App Engine Python Modules and inbound mail service

I am using App Engine Modules in my python project. (https://developers.google.com/appengine/docs/python/modules/#Python_Background_threads)

I am also receiving email in m project: https://developers.google.com/appengine/docs/python/mail/receivingmail

I want to direct the emails to my worker module and not the default module. To that end my worker.yaml has the following settings

worker.yaml

    api_version: 1
    application: integrate
    module: worker
    version: 1-0-0
    runtime: python27
    threadsafe: true

    inbound_services:
    - mail

    builtins:
    - deferred: on

    handlers:

    - url: /admin/.+
      script: src.worker.main.app
      login: admin

    - url: /_ah/mail/.+
      script: src.worker.main.app
      login: admin

    - url: /.*
      script: src.worker.main.app

app.yaml

    api_version: 1
    application: integrate
    version: 1-0-0
    runtime: python27
    threadsafe: true

    builtins:
    - deferred: on

    handlers:

    - url: /admin/.+
      script: src.default.main.app
      login: admin

    - url: /.*
      script: src.default.main.app

I even tried adding a dispatch.yaml

    application: integrate

    dispatch:
    - url: "*/_ah/mail/.+"
      module: worker

But no matter what I do the emails which reach my app are handled by the default module. Any idea what I am missing here? I see the emails coming in but no matter what I do they only go to the default module.


Inbound services could be used only within default module and that is expected behavior. The fact that it works for you locally in devserver is a bug, actually.


Just some additional info for the answer which may help folks in a similar situation.

I noticed in the DevServer log:

"Skipping dispatch.yaml rules because /_ah/mail/[EMAIL_ADDRESS_FOR_APP] is not a dispatchable path."

This is no doubt due to local config, however.

Regardless, the workaround I have now using Tasks is:

  • Dispatch or directly handle Inbound Mail in the default module
  • Provide a script handler that creates a Task, taking the relevant MailMessage data as the payload
  • Set the TaskQueue in queue.yaml to target the module you wish to process the payload data, eg a 'worker' module
  • 链接地址: http://www.djcxy.com/p/16312.html

    上一篇: 如何将目录复制到使用bash安装的目录中?

    下一篇: App Engine Python模块和入站邮件服务