aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/emails.py
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2014-06-09 14:04:38 +0200
committerFrançois Schmidts <francois.schmidts@gmail.com>2014-06-09 15:15:25 +0200
commit16ec162838eb8ab891f5b04351bb202d84a2b834 (patch)
tree975f0b567f48604f976adf35ba62f8a536a5ab16 /pyaggr3g470r/emails.py
parentsupporting feed without date or with ill formated date (diff)
downloadnewspipe-16ec162838eb8ab891f5b04351bb202d84a2b834.tar.gz
newspipe-16ec162838eb8ab891f5b04351bb202d84a2b834.tar.bz2
newspipe-16ec162838eb8ab891f5b04351bb202d84a2b834.zip
making pyagregator runnable by apache
* adding bootstrap module for basic import * redoing logging (config, proper use of the logging module) * making secret part of config (random wouldn't work with apache since it uses different instances of python) * making server entry point not executing application if just imported * not writing file for opml when we can read it from memory
Diffstat (limited to 'pyaggr3g470r/emails.py')
-rw-r--r--pyaggr3g470r/emails.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/pyaggr3g470r/emails.py b/pyaggr3g470r/emails.py
index 6f424c31..ae73c0e1 100644
--- a/pyaggr3g470r/emails.py
+++ b/pyaggr3g470r/emails.py
@@ -1,26 +1,27 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
+import logging
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from postmark import PMMail
-import log
import utils
import conf
from decorators import async
-pyaggr3g470r_log = log.Log("mail")
+logger = logging.getLogger(__name__)
+
@async
def send_async_email(mfrom, mto, msg):
try:
s = smtplib.SMTP(conf.MAIL_HOST)
s.login(conf.MAIL_USERNAME, conf.MAIL_PASSWORD)
- except Exception as e:
- pyaggr3g470r_log.error(str(e))
+ except Exception:
+ logger.exception('send_async_email raised:')
else:
s.sendmail(mfrom, mto, msg.as_string())
s.quit()
@@ -50,12 +51,12 @@ def send_email(mfrom, mto, feed, article):
# the HTML message, is best and preferred.
msg.attach(part1)
msg.attach(part2)
-
+
try:
s = smtplib.SMTP(conf.MAIL_HOST)
s.login(conf.MAIL_USERNAME, conf.MAIL_PASSWORD)
- except Exception as e:
- pyaggr3g470r_log.error(str(e))
+ except Exception:
+ logger.exception("send_email raised:")
else:
s.sendmail(mfrom, mto, msg.as_string())
s.quit()
@@ -81,9 +82,10 @@ def send_heroku(user=None, bcc="", subject="", plaintext=""):
message.to = user.email
message.send()
except Exception as e:
- pyaggr3g470r_log.error(str(e))
+ logger.exception("send_heroku raised:")
raise e
+
def information_message(subject, plaintext):
"""
Send an information message to the users of the platform.
@@ -103,6 +105,7 @@ def information_message(subject, plaintext):
else:
pass
+
def new_account_notification(user):
"""
Account creation notification.
@@ -114,6 +117,7 @@ def new_account_notification(user):
else:
pass
+
def new_account_activation(user):
"""
Account activation notification.
@@ -125,8 +129,9 @@ def new_account_activation(user):
else:
pass
+
def new_article_notification(user, feed, article):
if conf.ON_HEROKU:
pass
else:
- send_email(conf.ADMIN_EMAIL, user.email, feed, article) \ No newline at end of file
+ send_email(conf.ADMIN_EMAIL, user.email, feed, article)
bgstack15