diff options
Diffstat (limited to 'newspipe/notifications')
-rw-r--r-- | newspipe/notifications/emails.py | 20 | ||||
-rw-r--r-- | newspipe/notifications/notifications.py | 8 |
2 files changed, 18 insertions, 10 deletions
diff --git a/newspipe/notifications/emails.py b/newspipe/notifications/emails.py index 9738ae95..8093b655 100644 --- a/newspipe/notifications/emails.py +++ b/newspipe/notifications/emails.py @@ -33,8 +33,11 @@ logger = logging.getLogger(__name__) @async_maker def send_async_email(mfrom, mto, msg): try: - s = smtplib.SMTP(application.config['NOTIFICATION_HOST']) - s.login(application.config['NOTIFICATION_USERNAME'], application.config['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 +59,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"] = application.config['NOTIFICATION_EMAIL'] + msg["From"] = application.config["NOTIFICATION_EMAIL"] msg["To"] = to msg["BCC"] = bcc @@ -71,12 +74,17 @@ def send_smtp(to="", bcc="", subject="", plaintext="", html=""): msg.attach(part2) try: - s = smtplib.SMTP(application.config['NOTIFICATION_HOST']) - s.login(application.config['NOTIFICATION_USERNAME'], application.config['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( - application.config['NOTIFICATION_EMAIL'], msg["To"] + ", " + msg["BCC"], msg.as_string() + application.config["NOTIFICATION_EMAIL"], + msg["To"] + ", " + msg["BCC"], + msg.as_string(), ) s.quit() diff --git a/newspipe/notifications/notifications.py b/newspipe/notifications/notifications.py index 71ab0cf8..f5421e59 100644 --- a/newspipe/notifications/notifications.py +++ b/newspipe/notifications/notifications.py @@ -33,20 +33,20 @@ def new_account_notification(user, email): """ token = generate_confirmation_token(user.nickname) expire_time = datetime.datetime.now() + datetime.timedelta( - seconds=application.config['TOKEN_VALIDITY_PERIOD'] + seconds=application.config["TOKEN_VALIDITY_PERIOD"] ) plaintext = render_template( "emails/account_activation.txt", user=user, - platform_url=application.config['PLATFORM_URL'], + platform_url=application.config["PLATFORM_URL"], token=token, expire_time=expire_time, ) emails.send( to=email, - bcc=application.config['NOTIFICATION_EMAIL'], + bcc=application.config["NOTIFICATION_EMAIL"], subject="[Newspipe] Account creation", plaintext=plaintext, ) @@ -59,7 +59,7 @@ def new_password_notification(user, password): plaintext = render_template("emails/new_password.txt", user=user, password=password) emails.send( to=user.email, - bcc=application.config['NOTIFICATION_EMAIL'], + bcc=application.config["NOTIFICATION_EMAIL"], subject="[Newspipe] New password", plaintext=plaintext, ) |