app.yaml
[text]
– url: /_ah/mail/.+
script: handle_incoming_email.app
login: admin
…
inbound_services:
– mail
[/text]
handle_incoming_email.app
[python]
import logging
import webapp2
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
class ReceiveEmail(InboundMailHandler):
def receive(self,message):
logging.info("Received email from %s" % message.sender)
plaintext = message.bodies(content_type=’text/plain’)
for text in plaintext:
txtmsg = ""
txtmsg = text[1].decode()
logging.info("Body is %s" % txtmsg)
self.response.out.write(txtmsg)
app = webapp2.WSGIApplication([
ReceiveEmail.mapping()
], debug=True)
[/python]