diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-09 23:16:05 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-09 23:16:05 +0100 |
commit | 3ab6290d4994b33cdbf831523938cdb18a13bf49 (patch) | |
tree | 685980f53aaa3eda4e27ddfc7032554f55528e57 /newspipe/notifications/emails.py | |
parent | Improved method to detect current version of the Newspipe instance. (diff) | |
download | newspipe-3ab6290d4994b33cdbf831523938cdb18a13bf49.tar.gz newspipe-3ab6290d4994b33cdbf831523938cdb18a13bf49.tar.bz2 newspipe-3ab6290d4994b33cdbf831523938cdb18a13bf49.zip |
Refactoring the backend.
Diffstat (limited to 'newspipe/notifications/emails.py')
-rw-r--r-- | newspipe/notifications/emails.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/newspipe/notifications/emails.py b/newspipe/notifications/emails.py index dcfcf771..9738ae95 100644 --- a/newspipe/notifications/emails.py +++ b/newspipe/notifications/emails.py @@ -24,8 +24,8 @@ import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -import conf -from web.decorators import async_maker +from newspipe.bootstrap import application +from newspipe.web.decorators import async_maker logger = logging.getLogger(__name__) @@ -33,8 +33,8 @@ logger = logging.getLogger(__name__) @async_maker def send_async_email(mfrom, mto, msg): try: - s = smtplib.SMTP(conf.NOTIFICATION_HOST) - s.login(conf.NOTIFICATION_USERNAME, conf.NOTIFICATION_PASSWORD) + s = smtplib.SMTP(application.config['NOTIFICATION_HOST']) + s.login(application.config['NOTIFICATION_USERNAME'], application.config['NOTIFICATION_PASSWORD']) except Exception: logger.exception("send_async_email raised:") else: @@ -56,7 +56,7 @@ def send_smtp(to="", bcc="", subject="", plaintext="", html=""): # Create message container - the correct MIME type is multipart/alternative. msg = MIMEMultipart("alternative") msg["Subject"] = subject - msg["From"] = conf.NOTIFICATION_EMAIL + msg["From"] = application.config['NOTIFICATION_EMAIL'] msg["To"] = to msg["BCC"] = bcc @@ -71,12 +71,12 @@ def send_smtp(to="", bcc="", subject="", plaintext="", html=""): msg.attach(part2) try: - s = smtplib.SMTP(conf.NOTIFICATION_HOST) - s.login(conf.NOTIFICATION_USERNAME, conf.NOTIFICATION_PASSWORD) + s = smtplib.SMTP(application.config['NOTIFICATION_HOST']) + s.login(application.config['NOTIFICATION_USERNAME'], application.config['NOTIFICATION_PASSWORD']) except Exception: logger.exception("send_smtp raised:") else: s.sendmail( - conf.NOTIFICATION_EMAIL, msg["To"] + ", " + msg["BCC"], msg.as_string() + application.config['NOTIFICATION_EMAIL'], msg["To"] + ", " + msg["BCC"], msg.as_string() ) s.quit() |