aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-05-13 20:43:41 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-05-13 20:43:41 +0200
commitfdca0f720707eb015b2150bd9228fdcc85e6ef3a (patch)
tree22c08e2ed309ce107dc65dc5d8d550e977637123
parentLoad MAILGUN_SMTP_SERVER env variable. (diff)
downloadnewspipe-fdca0f720707eb015b2150bd9228fdcc85e6ef3a.tar.gz
newspipe-fdca0f720707eb015b2150bd9228fdcc85e6ef3a.tar.bz2
newspipe-fdca0f720707eb015b2150bd9228fdcc85e6ef3a.zip
trying to send email with postmark
-rw-r--r--conf.py3
-rw-r--r--pyaggr3g470r/emails.py23
-rw-r--r--pyaggr3g470r/views.py5
-rw-r--r--requirements.txt1
4 files changed, 16 insertions, 16 deletions
diff --git a/conf.py b/conf.py
index f289c74f..aba7253d 100644
--- a/conf.py
+++ b/conf.py
@@ -79,8 +79,7 @@ else:
MAIL_ENABLED = True
ADMIN_EMAIL = os.environ.get('ADMIN_EMAIL', '')
- MAILGUN_DOMAIN = os.environ.get('MAILGUN_SMTP_SERVER', '')
- MAILGUN_KEY = os.environ.get('MAILGUN_API_KEY', '')
+ POSTMARK_API_KEY = os.environ.get('POSTMARK_API_KEY', '')
WEBZINE_ROOT = "/tmp/"
diff --git a/pyaggr3g470r/emails.py b/pyaggr3g470r/emails.py
index 55ff4504..61851f22 100644
--- a/pyaggr3g470r/emails.py
+++ b/pyaggr3g470r/emails.py
@@ -5,7 +5,7 @@ import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
-import requests
+from postmark import PMMail
import log
import utils
@@ -71,19 +71,16 @@ def new_account_notification(user):
(conf.PLATFORM_URL + 'confirm_account/' + user.activation_key)
plaintext = utils.clear_string(html)
- r = requests.post("https://api.mailgun.net/v2/%s/messages" % conf.MAILGUN_DOMAIN,
- auth=("api", conf.MAILGUN_KEY),
- data={
- "from": conf.ADMIN_EMAIL,
- "to": user.email,
- "subject": "[pyAggr3g470r] Account activation",
- "text": plaintext,
- "html": html
- }
- )
- return r
+
+ message = PMMail(api_key = conf.POSTMARK_API_KEY,
+ subject = "[pyAggr3g470r] Account activation",
+ sender = conf.ADMIN_EMAIL,
+ to = user.email,
+ text_body = plaintext)
+
+ message.send()
except Exception as e:
- print str(e)
+ raise e
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index 58feb72b..108a3894 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -186,7 +186,10 @@ def signup():
return render_template('signup.html', form=form)
# Send the confirmation email
- result = emails.new_account_notification(user)
+ try:
+ emails.new_account_notification(user)
+ except Exception as e:
+ print str(e)
if result.status_code != 200:
flash(gettext('Problem while sending activation email: '+ str(result.text)), 'danger')
diff --git a/requirements.txt b/requirements.txt
index 8a4ab9dc..26567d10 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -13,5 +13,6 @@ Flask-WTF
Flask-Babel
Flask-Gravatar
WTForms
+postmark
gevent
whoosh
bgstack15