Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

support@ email handling, minimal testing

  • Loading branch information...
commit 004413e4bbc38721d8851bc3c6b0ba5c63e3443b 1 parent ae896ad
@thenoviceoof authored
Showing with 41 additions and 0 deletions.
  1. +7 −0 app.yaml
  2. +34 −0 handle_support.py
View
7 app.yaml
@@ -14,5 +14,12 @@ handlers:
- url: /callback
script: WIND_auth.py
+- url: /_ah/mail/support@.*\.appspotmail\.com
+ script: handle_support.py
+ login: admin
+
- url: /.*
script: flyer.py
+
+inbound_services:
+- mail
View
34 handle_support.py
@@ -0,0 +1,34 @@
+from google.appengine.api import mail
+from google.appengine.runtime import apiproxy_errors
+from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
+
+from google.appengine.ext import webapp
+from google.appengine.ext.webapp.util import run_wsgi_app
+
+import logging
+
+from config import ADMIN_EMAIL
+
+class SupportEmailHandler(InboundMailHandler):
+ def receive(self, mail_message):
+ log = logging.getLogger(__name__)
+ msg = mail.EmailMessage(sender=mail_message.sender,
+ to=ADMIN_EMAIL)
+ msg.subject = "[Floke Support] %s" % mail_message.subject
+ msg.html = "".join([b[1].decode() for b in mail_message.bodies()])
+ try:
+ msg.send()
+ except apiproxy_errors.OverQuotaError, (message,):
+ # Log the error
+ log.error("Could not forward email")
+ log.error(str(mail_message))
+
+application = webapp.WSGIApplication([
+ SupportEmailHandler.mapping()
+ ], debug=True)
+
+def main():
+ run_wsgi_app(application)
+
+if __name__ == "__main__":
+ main()
Please sign in to comment.
Something went wrong with that request. Please try again.