-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincoming.py
More file actions
20 lines (17 loc) · 785 Bytes
/
incoming.py
File metadata and controls
20 lines (17 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from google.appengine.ext import webapp
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import urlfetch
import urllib
class MailHandler(InboundMailHandler):
def receive(self, message):
content_type, encoded = message.bodies(content_type='text/plain').next()
body = encoded.decode()
sender = message.sender
subject = message.subject
urlfetch.fetch("http://yourotherapp.example.com/private/emails/handle_incoming", urllib.urlencode({'body':body, 'sender':sender, 'subject':subject}), urlfetch.POST)
application = webapp.WSGIApplication([MailHandler.mapping()], debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()