mirror of https://github.com/jumpserver/jumpserver
perf: Improve error handling for email sending in tasks
parent
be24f28d9b
commit
835eb2e3d0
|
@ -65,13 +65,13 @@ def send_mail_async(*args, **kwargs):
|
||||||
"send_mail_async called with subject=%r, recipients=%r", subject, recipient_list
|
"send_mail_async called with subject=%r, recipients=%r", subject, recipient_list
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
users = User.objects.filter(email__in=recipient_list).all()
|
||||||
users = User.objects.filter(email__in=recipient_list).all()
|
for user in users:
|
||||||
for user in users:
|
try:
|
||||||
with activate_user_language(user):
|
with activate_user_language(user):
|
||||||
send_mail(connection=get_email_connection(), *args, **kwargs)
|
send_mail(connection=get_email_connection(), *args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Sending mail error: {}".format(e))
|
logger.error(f"Sending mail to {user.email} error: {e}")
|
||||||
|
|
||||||
|
|
||||||
@shared_task(
|
@shared_task(
|
||||||
|
|
Loading…
Reference in New Issue