Paste #19

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import logging

from google.appengine.api import mail
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import mail_handlers

class MailHandler(mail_handlers.InboundMailHandler):
 def receive(self, message):
   bodies = message.bodies(content_type='text/plain')
   for body in bodies:
     logging.debug("charset: %s" % body[1].charset)
     logging.debug("encoding: %s" % body[1].encoding)
     logging.debug("payload: %s" % body[1].payload)

application = webapp.WSGIApplication([('/.*', MailHandler)],
                                    debug=True)

def main():
 logging.getLogger().setLevel(logging.DEBUG)
 run_wsgi_app(application)

if __name__ == "__main__":
 main()