From b99e26d83fc2b416dd54cd6ad470e823e9928c6f Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Wed, 12 Nov 2025 16:28:11 +0100 Subject: [PATCH] Don't log non-sent emails e.g. for users with their email addresses blanked out See #86 --- bugsink/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bugsink/utils.py b/bugsink/utils.py index 6df2428..80f05df 100644 --- a/bugsink/utils.py +++ b/bugsink/utils.py @@ -22,6 +22,12 @@ logger = logging.getLogger("bugsink.email") def send_rendered_email(subject, base_template_name, recipient_list, context=None): from phonehome.models import Installation + # Clean up; Django will do the same: https://github.com/django/django/blob/main/django/core/mail/message.py#L354 + # However, by doing the filter here we avoid logging something that is not reflective of what will actually happen. + recipient_list = [r for r in recipient_list if r] + if not recipient_list: + return + if not Installation.check_and_inc_email_quota(timezone.now()): logger.warning( "Email quota exceeded; not sending email with subject '%s' to %s",