diff --git a/gestioasso/settings/cof_prod.py b/gestioasso/settings/cof_prod.py index ebfef337..7e24f936 100644 --- a/gestioasso/settings/cof_prod.py +++ b/gestioasso/settings/cof_prod.py @@ -207,7 +207,8 @@ MAIL_DATA = { }, "rappels": {"FROM": "Le BdA ", "REPLYTO": "Le BdA "}, "rappel_negatif": { - "FROM": "La K-Fêt ", + "FROM": "La K-Fêt ", + "REPLYTO": "La K-Fêt ", }, "revente": { "FROM": "BdA-Revente ", diff --git a/kfet/models.py b/kfet/models.py index d2ff42f9..0b5b7481 100644 --- a/kfet/models.py +++ b/kfet/models.py @@ -2,7 +2,7 @@ import re from django.conf import settings from django.contrib.auth.models import User -from django.core.mail import send_mail +from django.core.mail import EmailMessage from django.core.validators import RegexValidator from django.db import models, transaction from django.db.models import F @@ -298,10 +298,11 @@ class AccountNegative(models.Model): """ Envoie un mail de rappel signalant que la personne est en négatif. """ - # On envoie le mail - send_mail( - "Compte K-Psul négatif", - loader.render_to_string( + mail_data = settings.MAIL_DATA["rappel_negatif"] + + email = EmailMessage( + subject="Compte K-Psul négatif", + body=loader.render_to_string( "kfet/mails/rappel.txt", context={ "account": self.account, @@ -309,9 +310,14 @@ class AccountNegative(models.Model): "start_date": self.start, }, ), - settings.MAIL_DATA["rappel_negatif"]["FROM"], - [self.account.email], + from_email=mail_data["FROM"], + to=[self.account.email], + reply_to=[mail_data["REPLYTO"]], ) + + # On envoie le mail + email.send() + # On enregistre le fait que l'envoi a bien eu lieu self.last_rappel = timezone.now() self.save()