|
|
@@ -13,41 +13,30 @@ from core import logconf
|
|
|
from core.mail import Mail
|
|
|
from core.pde import ControlesDb
|
|
|
|
|
|
-logger = logging.getLogger("ctrl_mailing")
|
|
|
-logconf.start("ctrl_mailing", logging.DEBUG)
|
|
|
+logger = logging.getLogger("mails_rappel_ctrl")
|
|
|
+logconf.start("mails_rappel_ctrl", logging.DEBUG)
|
|
|
|
|
|
# # CONFIG
|
|
|
+
|
|
|
# Nombre de jours à partir duquel les mails sont envoyés
|
|
|
SEUIL_DUREE = 15
|
|
|
|
|
|
# Demarrer la requete de sélection à partir du chantier:
|
|
|
CHANTIER_DEPART = 175000
|
|
|
|
|
|
-# Contact
|
|
|
-CONTACT = "parc.erstein@bas-rhin.fr"
|
|
|
-
|
|
|
# Adresse mail depuis laquelle les mails sont envoyés
|
|
|
-SENDER = "mail.auto@bas-rhin.fr"
|
|
|
+SENDER = "ne-pas-repondre@bas-rhin.fr"
|
|
|
|
|
|
# Objet des mails automatiques
|
|
|
SUBJECT = "Mail automatique - Rappel"
|
|
|
|
|
|
+# Contact
|
|
|
+CONTACT = "jacky.klein@bas-rhin.fr"
|
|
|
+
|
|
|
# Contenu des mails automatiques
|
|
|
# NB: variables optionelles utilisables dans CONTENT: {chantier_id}, {date_status}, {contact}
|
|
|
-CONTENT = """Bonjour,
|
|
|
--- Ceci est un rappel automatique, veuillez ne pas répondre à cette adresse --
|
|
|
-
|
|
|
-> le chantier numéro {chantier_id} est en attente d'une intervention depuis le {date_status}.
|
|
|
-
|
|
|
-Pour plus d'information: {contact}
|
|
|
-
|
|
|
-Merci,
|
|
|
-Le Parc Départemental d'Erstein
|
|
|
-"""
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+with open("mail.html", encoding="utf-8") as f:
|
|
|
+ content = f.read()
|
|
|
|
|
|
# # INITIALISATION
|
|
|
|
|
|
@@ -101,9 +90,11 @@ for row in qry:
|
|
|
|
|
|
logger.info("> Chantier %s: envoi d'un mail à %s", chantier_id, mail_to)
|
|
|
mail = Mail(SENDER,
|
|
|
- mail_to,
|
|
|
+ [mail_to],
|
|
|
SUBJECT,
|
|
|
- CONTENT.format(chantier_id=chantier_id,
|
|
|
+ content.format(
|
|
|
+ chantier_id=chantier_id,
|
|
|
date_status=since,
|
|
|
contact=CONTACT)
|
|
|
)
|
|
|
+ mail.send()
|