# Bcc mail sending
* extends mailer class with bcc based mailing * switches all team based mail sending (multiple mail adresses) to bcc based mailing * adds smaller versions of tech-croc error images for 4xx and 5xx errors for faster rendering
This commit is contained in:
+21
-8
@@ -5,7 +5,7 @@ Contact: michel.peltriaux@sgdnord.rlp.de
|
||||
Created on: 09.11.20
|
||||
|
||||
"""
|
||||
from django.core.mail import send_mail
|
||||
from django.core.mail import send_mail, EmailMultiAlternatives
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
@@ -45,6 +45,19 @@ class Mailer:
|
||||
auth_password=self.auth_password
|
||||
)
|
||||
|
||||
def send_via_bcc(self, recipient_list: list, subject: str, msg: str):
|
||||
"""
|
||||
Sends a mail with subject and message where recipients will be masked via bcc
|
||||
"""
|
||||
email_obj = EmailMultiAlternatives(
|
||||
subject,
|
||||
msg,
|
||||
self.from_mail,
|
||||
bcc=recipient_list,
|
||||
)
|
||||
email_obj.attach_alternative(msg, "text/html")
|
||||
return email_obj.send(fail_silently=self.fail_silently)
|
||||
|
||||
def send_mail_shared_access_removed(self, obj, user, municipals_names):
|
||||
""" Send a mail if user has no access to the object anymore
|
||||
|
||||
@@ -115,7 +128,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/sharing/shared_access_given_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared access given").format(obj.identifier),
|
||||
msg
|
||||
@@ -141,7 +154,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/sharing/shared_access_removed_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared access removed").format(obj.identifier),
|
||||
msg
|
||||
@@ -167,7 +180,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/recording/shared_data_unrecorded_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared data unrecorded").format(obj.identifier),
|
||||
msg
|
||||
@@ -193,7 +206,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/recording/shared_data_recorded_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared data recorded").format(obj.identifier),
|
||||
msg
|
||||
@@ -219,7 +232,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/checking/shared_data_checked_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared data checked").format(obj.identifier),
|
||||
msg
|
||||
@@ -244,7 +257,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/other/deduction_changed_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Deduction changed").format(obj.identifier),
|
||||
msg
|
||||
@@ -270,7 +283,7 @@ class Mailer:
|
||||
}
|
||||
msg = render_to_string("email/deleting/shared_data_deleted_team.html", context)
|
||||
user_mail_address = users_to_notify.values_list("email", flat=True)
|
||||
self.send(
|
||||
self.send_via_bcc(
|
||||
user_mail_address,
|
||||
_("{} - Shared data deleted").format(obj.identifier),
|
||||
msg
|
||||
|
||||
Reference in New Issue
Block a user