Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

there@ support

  • Loading branch information...
commit bc6c62ea902740514acbf28168a50319688b0078 1 parent b72f268
Brian Klug authored
Showing with 28 additions and 25 deletions.
  1. +1 −2  app.yaml
  2. +27 −0 main.py
  3. +0 −23 there.py
3  app.yaml
View
@@ -10,9 +10,8 @@ handlers:
- url: /static
static_dir: static
- url: /_ah/mail/there@.+
- script: there.py
+ script: main.py
- url: .*
script: main.py
-
27 main.py
View
@@ -13,6 +13,11 @@
from datetime import datetime
import urllib, hashlib, time, random
from django.utils import simplejson
+import logging, email
+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 mail
GREETINGS = ['hello', 'hi', 'ahoy', 'welcome', 'greetings', 'howdy']
@@ -146,9 +151,31 @@ def to_dict(staffer):
self.response.out.write(simplejson.dumps([to_dict(staffer) for staffer in staff]))
+class MailHandler(InboundMailHandler):
+ def receive(self, mail_message):
+
+ staff = Signin.get_active_staff()
+ count = staff.count(1000)
+ if count > 0:
+ staff = [s.email for s in staff.fetch(1000)]
+ #for s in cc:
+ mail.send_mail(
+ sender=mail_message.sender,
+ #to=s,
+ to=(', '.join(staff)),
+ subject="[there@] " + mail_message.subject,
+ body=mail_message.body)
+ else:
+ mail.send_mail(
+ sender="there@hackerdojo.com",
+ to=mail_message.sender,
+ subject="there@ error",
+ body="Sorry, doesn't look like any staff is signed in")
+
def main():
application = webapp.WSGIApplication([
('/', MainHandler),
+ (r'^/_ah/mail/there.*', MailHandler),
('/ministaff', MiniStaffHandler),
('/staff', StaffHandler),
('/open', OpenHandler),
23 there.py
View
@@ -1,23 +0,0 @@
-import logging, email
-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 mail
-
-class MailHandler(InboundMailHandler):
- def receive(self, mail_message):
- logging.info("Received a message from: " + mail_message.sender)
-
- mail.send_mail(
- sender=mail_message.sender,
- to="brian.klug@gmail.com",
- subject=mail_message.subject,
- body=mail_message.body)
-
-application = webapp.WSGIApplication([
- MailHandler.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.