From f524dcaf589d74fc5ca6fe95b53917ce85ae38b4 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 19 Jan 2022 22:40:41 +0100 Subject: [PATCH] Variable SCODOC_MAIL_FROM pour les envois d'exceptions --- app/__init__.py | 2 +- app/auth/email.py | 2 +- app/scodoc/sco_preferences.py | 7 ++++--- config.py | 3 +++ sco_version.py | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 04e28207..258720ac 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -249,7 +249,7 @@ def create_app(config_class=DevConfig): host_name = socket.gethostname() mail_handler = ScoSMTPHandler( mailhost=(app.config["MAIL_SERVER"], app.config["MAIL_PORT"]), - fromaddr="no-reply@" + app.config["MAIL_SERVER"], + fromaddr=app.config["SCODOC_MAIL_FROM"], toaddrs=["exception@scodoc.org"], subject="ScoDoc Exception", # unused see ScoSMTPHandler credentials=auth, diff --git a/app/auth/email.py b/app/auth/email.py index 9ac8a017..61759691 100644 --- a/app/auth/email.py +++ b/app/auth/email.py @@ -8,7 +8,7 @@ def send_password_reset_email(user): token = user.get_reset_password_token() send_email( "[ScoDoc] Réinitialisation de votre mot de passe", - sender=current_app.config["ADMINS"][0], + sender=current_app.config["SCODOC_MAIL_FROM"], recipients=[user.email], text_body=render_template("email/reset_password.txt", user=user, token=token), html_body=render_template("email/reset_password.html", user=user, token=token), diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index b38fb736..77242d65 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -111,8 +111,9 @@ get_base_preferences(formsemestre_id) """ import flask -from flask import g, url_for, request -from flask_login import current_user +from flask import g, request, current_app + +# from flask_login import current_user from app.models import Departement from app.scodoc import sco_cache @@ -1537,7 +1538,7 @@ class BasePreferences(object): ( "email_from_addr", { - "initvalue": "noreply@scodoc.example.com", + "initvalue": current_app.config["SCODOC_MAIL_FROM"], "title": "adresse mail origine", "size": 40, "explanation": "adresse expéditeur pour les envois par mails (bulletins)", diff --git a/config.py b/config.py index ae507b1e..fca2fc51 100755 --- a/config.py +++ b/config.py @@ -26,6 +26,9 @@ class Config: SCODOC_ADMIN_LOGIN = os.environ.get("SCODOC_ADMIN_LOGIN") or "admin" ADMINS = [SCODOC_ADMIN_MAIL] SCODOC_ERR_MAIL = os.environ.get("SCODOC_ERR_MAIL") + # Le "from" des mails émis. Attention: peut être remplacée par la préférence email_from_addr: + SCODOC_MAIL_FROM = os.environ.get("SCODOC_MAIL_FROM") or ("no-reply@" + MAIL_SERVER) + BOOTSTRAP_SERVE_LOCAL = os.environ.get("BOOTSTRAP_SERVE_LOCAL") SCODOC_DIR = os.environ.get("SCODOC_DIR", "/opt/scodoc") SCODOC_VAR_DIR = os.environ.get("SCODOC_VAR_DIR", "/opt/scodoc-data") diff --git a/sco_version.py b/sco_version.py index 88ff029d..5ddad619 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.1.27" +SCOVERSION = "9.1.28" SCONAME = "ScoDoc"