This is really useful. Thanks for sharing. Would you add a web2pyslice.com
On Apr 21, 4:52 pm, mattynoce <[email protected]> wrote: > just as a follow-up here, i got this to work simply using a combination of > what everyone said. here's what i did: > > i added the following to my app.yaml above the handlers: section: > > inbound_services: > - mail > > under handlers (and for me, below remote_api), i added the following code: > - url: /_ah/mail/.+ > script: gaehandler.py > login: admin > > i then went followed jonathan's advice and copied router.example.py in the > web2py folder to routes.py, and uncommented (and changed "welcome" to > "init") the following lines: > > routers = dict( > > # base router > BASE = dict( > default_application = 'init', # used to be 'welcome' > ), > ) > > i created a table in db.py as such: > > db.define_table('email', > Field('body', 'string') > ) > > finally, i went to my init/controllers directory, created _ah.py and put > this inside: > > def mail(): > # more details > here:http://code.google.com/appengine/docs/python/mail/receivingmail.html > from google.appengine.api.mail import InboundEmailMessage > > message = InboundEmailMessage(request.body) > html_bodies = message.bodies('text/html') > for content_type, body in html_bodies: > decoded_html = body.decode() > > db.email[0] = dict(body=decoded_html) > > that's it -- it works, and the body of the email ends up in my db. i hope > that helps. > > matt

