From 5400ca6a7df75b930fc7b2a0401865e144866dbc Mon Sep 17 00:00:00 2001 From: Nicolas Ledez Date: Fri, 18 Oct 2024 14:26:39 +0200 Subject: [PATCH] Add MAIL_DEBUG_BODY and modify the behaviour of MAIL_DEBUG --- zou/app/config.py | 3 ++- zou/app/utils/emails.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/zou/app/config.py b/zou/app/config.py index e737b12303..e44a37fd76 100644 --- a/zou/app/config.py +++ b/zou/app/config.py @@ -81,7 +81,8 @@ MAIL_PORT = os.getenv("MAIL_PORT", 25) MAIL_USERNAME = os.getenv("MAIL_USERNAME", "") MAIL_PASSWORD = os.getenv("MAIL_PASSWORD", "") -MAIL_DEBUG = envtobool("MAIL_DEBUG", False) +MAIL_DEBUG = envtobool("MAIL_DEBUG", 0) +MAIL_DEBUG_BODY = envtobool("MAIL_DEBUG_BODY", False) MAIL_USE_TLS = envtobool("MAIL_USE_TLS", False) MAIL_USE_SSL = envtobool("MAIL_USE_SSL", False) MAIL_DEFAULT_SENDER = os.getenv( diff --git a/zou/app/utils/emails.py b/zou/app/utils/emails.py index 55160dcbd8..02f25245df 100644 --- a/zou/app/utils/emails.py +++ b/zou/app/utils/emails.py @@ -12,9 +12,9 @@ def send_email(subject, html, recipient_email, body=None): """ if body is None: body = strip_html_tags(html) - if app.config["MAIL_DEBUG"]: + if app.config["MAIL_DEBUG_BODY"]: print(body) - elif app.config["MAIL_ENABLED"]: + if app.config["MAIL_ENABLED"]: with app.app_context(): try: mail_default_sender = app.config["MAIL_DEFAULT_SENDER"]