From 204792b750e693eb2365da052a8e48211e683e43 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 17 Jan 2021 23:31:58 +0100 Subject: [PATCH] stages/email: fix email task not falling back to use_global_settings --- authentik/events/models.py | 2 +- authentik/stages/email/tasks.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/authentik/events/models.py b/authentik/events/models.py index 8fcfe3b3a..2e5875f46 100644 --- a/authentik/events/models.py +++ b/authentik/events/models.py @@ -282,7 +282,7 @@ class NotificationTransport(models.Model): try: # pyright: reportGeneralTypeIssues=false return send_mail(mail.__dict__) # pylint: disable=no-value-for-parameter - except (SMTPException, ConnectionError) as exc: + except (SMTPException, ConnectionError, OSError) as exc: raise NotificationTransportError from exc def __str__(self) -> str: diff --git a/authentik/stages/email/tasks.py b/authentik/stages/email/tasks.py index 0c62ab511..84cb73134 100644 --- a/authentik/stages/email/tasks.py +++ b/authentik/stages/email/tasks.py @@ -31,6 +31,7 @@ def send_mails(stage: EmailStage, *messages: list[EmailMultiAlternatives]): autoretry_for=( SMTPException, ConnectionError, + OSError, ), retry_backoff=True, base=MonitoredTask, @@ -44,7 +45,7 @@ def send_mail( self.set_uid(slugify(message_id.replace(".", "_").replace("@", "_"))) try: if not email_stage_pk: - stage: EmailStage = EmailStage() + stage: EmailStage = EmailStage(use_global_settings=True) else: stage: EmailStage = EmailStage.objects.get(pk=email_stage_pk) backend = stage.backend