diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-14 14:26:50 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2020-03-14 14:26:50 +0100 |
commit | 667d59bbeea4ac768949ea1cac66e65cbf8ca350 (patch) | |
tree | c3ccc784f8d098fee7761297835f4888da7c536a | |
parent | Preparing new 9.1.0 release. (diff) | |
download | newspipe-667d59bbeea4ac768949ea1cac66e65cbf8ca350.tar.gz newspipe-667d59bbeea4ac768949ea1cac66e65cbf8ca350.tar.bz2 newspipe-667d59bbeea4ac768949ea1cac66e65cbf8ca350.zip |
Fixed email notifications.
-rw-r--r-- | instance/production.py | 3 | ||||
-rw-r--r-- | newspipe/notifications/emails.py | 15 | ||||
-rw-r--r-- | newspipe/notifications/notifications.py | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/instance/production.py b/instance/production.py index 798c5a04..46f16523 100644 --- a/instance/production.py +++ b/instance/production.py @@ -6,6 +6,7 @@ import os # Webserver HOST = "127.0.0.1" +PLATFORM_URL = "" PORT = 5000 DEBUG = False API_ROOT = "/api/v2.0" @@ -13,7 +14,6 @@ API_ROOT = "/api/v2.0" CSRF_ENABLED = True SECRET_KEY = "LCx3BchmHRxFzkEv4BqQJyeXRLXenf" SECURITY_PASSWORD_SALT = "L8gTsyrpRQEF8jNWQPyvRfv7U5kJkD" -TOKEN_VALIDITY_PERIOD = 3600 # Database DB_CONFIG_DICT = { @@ -46,6 +46,7 @@ MAIL_DEBUG = DEBUG MAIL_USERNAME = None MAIL_PASSWORD = None MAIL_DEFAULT_SENDER = "admin@admin.localhost" +TOKEN_VALIDITY_PERIOD = 3600 # Misc BASE_DIR = os.path.abspath(os.path.dirname(".")) diff --git a/newspipe/notifications/emails.py b/newspipe/notifications/emails.py index 31eceaeb..8c2f24a1 100644 --- a/newspipe/notifications/emails.py +++ b/newspipe/notifications/emails.py @@ -59,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["MAIL_DEFAULT_SENDER"] msg["To"] = to msg["BCC"] = bcc @@ -74,16 +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["MAIL_SERVER"]) + if application.config["MAIL_USERNAME"] is not None: + s.login( + application.config["MAIL_USERNAME"], + application.config["MAIL_PASSWORD"], + ) except Exception: logger.exception("send_smtp raised:") else: s.sendmail( - application.config["NOTIFICATION_EMAIL"], + application.config["MAIL_DEFAULT_SENDER"], msg["To"] + ", " + msg["BCC"], msg.as_string(), ) diff --git a/newspipe/notifications/notifications.py b/newspipe/notifications/notifications.py index 2e7ec399..df826452 100644 --- a/newspipe/notifications/notifications.py +++ b/newspipe/notifications/notifications.py @@ -47,7 +47,7 @@ def new_account_notification(user, email): emails.send( to=email, - bcc=application.config["NOTIFICATION_EMAIL"], + bcc=application.config["MAIL_DEFAULT_SENDER"], subject="[Newspipe] Account creation", plaintext=plaintext, ) |