On Apr 13, 2011, at 4:06 PM, Mike Giles wrote:
> 
> I'm playing around with web2py for the first time on a project that is
> using GAE to accept and process inbound email.  When mail comes in to
> GAE, you need to tell it what piece of code to run in your app.yaml to
> handle it:
> 
> - url: /_ah/mail/.+
>  script: applications/myapp/modules/incoming.py
>  login: admin
> 
> So my first question is where should I put the code that will handle
> this mail?  Is it a module?  A controller?

I think you want something like this:

- url: /_ah/mail/.+
 script: gaehandler.py

Create a controller named _ah.py, with a function mail(), and look in 
request.args(0) for the email address.

I think.

> 
> I based my rough prototype on the code from Google (http://
> code.google.com/appengine/docs/python/mail/receivingmail.html), which
> obviously has no knowledge of web2py.  However, in that code I want to
> store some data to the DB, using the model that I've defined in my
> db.py file.  Unfortunately, I'm getting the "NameError: global name
> 'db' is not defined" message when I try to do a query on the db.  The
> same code works fine if I stick it in the default controller of my
> app, so I'm curious what I need to do to make the two worlds connect
> (i.e. requests that come in through GAE inbound mail, and the rest of
> my app).
> 
> -Mike


Reply via email to