From fd65aa36adf792f1a563334ca454ee3f66fae83d Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Wed, 10 Jul 2024 13:52:03 +0200 Subject: [PATCH] fix(send_mail): Save after each sent mail, as the bottleneck is in the SMTP --- elections/utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/elections/utils.py b/elections/utils.py index 722372a..556f7a0 100644 --- a/elections/utils.py +++ b/elections/utils.py @@ -461,9 +461,8 @@ def send_mail(election: "Election", subject: str, body: str, reply_to: str) -> N for m, v in messages: try: m.send() + v.has_valid_email = True except smtplib.SMTPException: v.has_valid_email = False - else: - v.has_valid_email = True - User.objects.bulk_update(voters, ["password", "has_valid_email"]) + v.save()