perf: Improve error handling for email sending in tasks

pull/15786/head
wangruidong 2025-07-28 09:59:43 +08:00 committed by 老广
parent be24f28d9b
commit 835eb2e3d0
1 changed files with 5 additions and 5 deletions

View File

@ -65,13 +65,13 @@ def send_mail_async(*args, **kwargs):
"send_mail_async called with subject=%r, recipients=%r", subject, recipient_list
)
try:
users = User.objects.filter(email__in=recipient_list).all()
for user in users:
try:
with activate_user_language(user):
send_mail(connection=get_email_connection(), *args, **kwargs)
except Exception as e:
logger.error("Sending mail error: {}".format(e))
logger.error(f"Sending mail to {user.email} error: {e}")
@shared_task(