From a74a486d73acfcf2e86aa44b1890072f06edb173 Mon Sep 17 00:00:00 2001 From: Friedel Wolff Date: Wed, 21 Aug 2024 11:55:54 +0200 Subject: [PATCH] Obtain more email settings from environment We also provide the defaults as they are in Django, instead of implicitly setting them to None. --- .env.example | 7 ++++--- .env.testing | 1 - app/app/settings.py | 14 +++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 3b276aba..11c84ea7 100644 --- a/.env.example +++ b/.env.example @@ -10,12 +10,13 @@ LOGGING_HANDLERS_LEVEL=INFO LOGGING_LOGGERS_LEVEL=INFO LOGGING_LOGGERS_DJANGO_LEVEL=INFO TESTING_DIR=/app/general/tests/files/ -FEATURE_FLAG='' EMAIL_HOST='' -EMAIL_USE_TLS=True EMAIL_PORT=587 +EMAIL_USE_TLS=True EMAIL_HOST_USER='' EMAIL_HOST_PASSWORD='' +DEFAULT_FROM_EMAIL='' +SERVER_EMAIL='' +EMAIL_SUBJECT_PREFIX='' EMAIL_BACKEND_CONSOLE='True/False' -EMAIL_USE_TLS=True SECRET_KEY='' diff --git a/.env.testing b/.env.testing index deeebc6c..e74f436b 100644 --- a/.env.testing +++ b/.env.testing @@ -10,4 +10,3 @@ LOGGING_HANDLERS_LEVEL=INFO LOGGING_LOGGERS_LEVEL=INFO LOGGING_LOGGERS_DJANGO_LEVEL=INFO TESTING_DIR=/home/runner/work/term_platform/term_platform/app/general/tests/files/ -FEATURE_FLAG='' diff --git a/app/app/settings.py b/app/app/settings.py index 496d6863..865964e1 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -167,11 +167,15 @@ def __contains__(self, address): # Email settings -EMAIL_HOST = os.environ.get("EMAIL_HOST") -EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER") -EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD") -EMAIL_PORT = os.environ.get("EMAIL_PORT") -EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS") +EMAIL_HOST = os.environ.get("EMAIL_HOST", "localhost") +EMAIL_PORT = os.environ.get("EMAIL_PORT", 25) +EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS", False) +EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER", "") +EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD", "") +DEFAULT_FROM_EMAIL = os.environ.get("DEFAULT_FROM_EMAIL", "webmaster@localhost") +SERVER_EMAIL = os.environ.get("SERVER_EMAIL", "root@localhost") +EMAIL_SUBJECT_PREFIX = os.environ.get("EMAIL_SUBJECT_PREFIX", "[Django] ") +ADMINS = os.environ.get("ADMINS", "").split() email_backend_env = os.environ.get("EMAIL_BACKEND_CONSOLE", "False").lower() in ["true", "1", "yes"]