fix(send_mail): Save after each sent mail, as the bottleneck is in the SMTP

This commit is contained in:
Tom Hubrecht 2024-07-10 13:52:03 +02:00
parent 8f88eef5c7
commit fd65aa36ad

View file

@ -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()