Permalink
Browse files

strip recipients

  • Loading branch information...
1 parent 6909a13 commit 6ed7fb7cb7ac3cfd7a6369c310b40eeb1e03048a @qzio committed Mar 30, 2013
Showing with 17 additions and 7 deletions.
  1. +13 −7 mails.py
  2. +4 −0 requirements.txt
View
@@ -2,6 +2,7 @@
from flask import url_for
from flask_mail import Mail, Message
+import logging
mail = Mail()
@@ -12,13 +13,13 @@ def send_all(todolists, recipient):
msg = Message(mail_body,
sender="no-reply@localhost",
- recipients=[recipient])
+ recipients=[recipient.strip()])
- if mail.send(msg):
- print "mail sent successfully"
+ try:
+ mail.send(msg)
return True
- else:
- print "mail was NOT sent"
+ except Exception, e:
+ logging.error("Failed to send all lists to self: {0}".format(e))
return False
def send_list(todolist, recipient):
@@ -30,6 +31,11 @@ def send_list(todolist, recipient):
msg = Message(mail_body,
sender="no-reply@localhost",
- recipients=[recipient])
+ recipients=[recipient.strip()])
- mail.send(msg)
+ try:
+ mail.send(msg)
+ return True
+ except Exception, e:
+ logging.error("Failed to send list to friend: {0}".format(e))
+ return False
View
@@ -7,3 +7,7 @@ Werkzeug==0.8.3
argparse==1.2.1
blinker==1.2
wsgiref==0.1.2
+
+# Production:
+# gunicorn==0.17.2
+# MySQL-python==1.2.4

0 comments on commit 6ed7fb7

Please sign in to comment.