Variable SCODOC_MAIL_FROM pour les envois d'exceptions

This commit is contained in:
Emmanuel Viennet 2022-01-19 22:40:41 +01:00
parent 0e6d570168
commit f524dcaf58
5 changed files with 10 additions and 6 deletions

View File

@ -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,

View File

@ -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),

View File

@ -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)",

View File

@ -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")

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.1.27"
SCOVERSION = "9.1.28"
SCONAME = "ScoDoc"