diff --git a/src/pretix/base/migrations/0297_outgoingmail.py b/src/pretix/base/migrations/0297_outgoingmail.py index 7d80a92d67..034d77ac4e 100644 --- a/src/pretix/base/migrations/0297_outgoingmail.py +++ b/src/pretix/base/migrations/0297_outgoingmail.py @@ -32,6 +32,7 @@ class Migration(migrations.Migration): ("retry_after", models.DateTimeField(blank=True, null=True)), ("error", models.TextField(null=True)), ("error_detail", models.TextField(null=True)), + ("sensitive", models.BooleanField(default=False)), ("subject", models.TextField()), ("body_plain", models.TextField()), ("body_html", models.TextField(null=True)), @@ -40,7 +41,7 @@ class Migration(migrations.Migration): ("to", models.JSONField(default=list)), ("cc", models.JSONField(default=list)), ("bcc", models.JSONField(default=list)), - ("recipient_count", models.IntegerField(default=1)), + ("recipient_count", models.IntegerField()), ("should_attach_tickets", models.BooleanField(default=False)), ("should_attach_ical", models.BooleanField(default=False)), ("should_attach_other_files", models.JSONField(default=list)), diff --git a/src/pretix/base/models/customers.py b/src/pretix/base/models/customers.py index d7d34db98d..51fbd7490b 100644 --- a/src/pretix/base/models/customers.py +++ b/src/pretix/base/models/customers.py @@ -293,6 +293,7 @@ class Customer(LoggedModel): locale=self.locale, customer=self, organizer=self.organizer, + sensitive=True, ) def usable_gift_cards(self, used_cards=[]): diff --git a/src/pretix/base/models/mail.py b/src/pretix/base/models/mail.py index 4ac8a15077..2128c28592 100644 --- a/src/pretix/base/models/mail.py +++ b/src/pretix/base/models/mail.py @@ -135,6 +135,7 @@ class OutgoingMail(models.Model): null=True, blank=True, ) + sensitive = models.BooleanField(default=False) subject = models.TextField() body_plain = models.TextField() body_html = models.TextField(null=True) diff --git a/src/pretix/base/services/mail.py b/src/pretix/base/services/mail.py index 547e3b405f..90f15815e6 100644 --- a/src/pretix/base/services/mail.py +++ b/src/pretix/base/services/mail.py @@ -152,7 +152,8 @@ def mail(email: Union[str, Sequence[str]], subject: str, template: Union[str, La position: OrderPosition = None, *, headers: dict = None, sender: str = None, organizer: Organizer = None, customer: Customer = None, invoices: Sequence = None, attach_tickets=False, auto_email=True, user=None, attach_ical=False, attach_cached_files: Sequence = None, attach_other_files: list=None, - plain_text_only=False, no_order_links=False, cc: Sequence[str]=None, bcc: Sequence[str]=None): + plain_text_only=False, no_order_links=False, cc: Sequence[str]=None, bcc: Sequence[str]=None, + sensitive: bool=False): """ Sends out an email to a user. The mail will be sent synchronously or asynchronously depending on the installation. @@ -208,6 +209,9 @@ def mail(email: Union[str, Sequence[str]], subject: str, template: Union[str, La only allowed to use together with ``plain_text_only`` since HTML renderers add their own links. + :param sensitive: If set to ``True``, the email content will not be shown as part of log entries, used e.g. for + password resets. Bcc will also not be used. + :raises MailOrderException: on obvious, immediate failures. Not raising an exception does not necessarily mean that the email has been sent, just that it has been queued by the email backend. """ @@ -228,7 +232,7 @@ def mail(email: Union[str, Sequence[str]], subject: str, template: Union[str, La headers.setdefault('X-PX-Correlation', str(guid)) bcc = list(bcc or []) - if settings_holder and settings_holder.settings.mail_bcc: + if settings_holder and settings_holder.settings.mail_bcc and not sensitive: for bcc_mail in settings_holder.settings.mail_bcc.split(','): bcc.append(bcc_mail.strip()) @@ -321,6 +325,7 @@ def mail(email: Union[str, Sequence[str]], subject: str, template: Union[str, La should_attach_tickets=attach_tickets, should_attach_ical=attach_ical, should_attach_other_files=attach_other_files or [], + sensitive=sensitive, ) if invoices and not position: m.should_attach_invoices.add(*invoices) @@ -721,6 +726,7 @@ def mail_send_task(self, *args, outgoing_mail: int) -> bool: }, } ) + return True def mail_send(to: List[str], subject: str, body: str, html: Optional[str], sender: str, diff --git a/src/pretix/control/forms/organizer.py b/src/pretix/control/forms/organizer.py index 1f10385af7..a314b889a2 100644 --- a/src/pretix/control/forms/organizer.py +++ b/src/pretix/control/forms/organizer.py @@ -585,6 +585,7 @@ class MailSettingsForm(SettingsForm): help_text=''.join([ str(_("All emails will be sent to this address as a Bcc copy.")), str(_("You can specify multiple recipients separated by commas.")), + str(_("Sensitive emails like password resets will not be sent in Bcc.")), ]), validators=[multimail_validate], required=False, diff --git a/src/pretix/control/templates/pretixcontrol/organizers/outgoing_mail.html b/src/pretix/control/templates/pretixcontrol/organizers/outgoing_mail.html index 5183459db0..a8ec07722b 100644 --- a/src/pretix/control/templates/pretixcontrol/organizers/outgoing_mail.html +++ b/src/pretix/control/templates/pretixcontrol/organizers/outgoing_mail.html @@ -171,13 +171,39 @@
+ {% icon "eye-slash 4x" %} +
++ {% blocktrans trimmed %} + Sensitive content not shown for security reasons + {% endblocktrans %} +
+{{ mail.body_plain }}
+ {% if mail.sensitive %}
+ + {% icon "eye-slash 4x" %} +
++ {% blocktrans trimmed %} + Sensitive content not shown for security reasons + {% endblocktrans %} +
+{{ mail.body_plain }}
+ {% endif %}