stages/email: fix email task not falling back to use_global_settings

This commit is contained in:
Jens Langhammer 2021-01-17 23:31:58 +01:00
parent 8ffa3e5885
commit 204792b750
2 changed files with 3 additions and 2 deletions

View File

@ -282,7 +282,7 @@ class NotificationTransport(models.Model):
try: try:
# pyright: reportGeneralTypeIssues=false # pyright: reportGeneralTypeIssues=false
return send_mail(mail.__dict__) # pylint: disable=no-value-for-parameter 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 raise NotificationTransportError from exc
def __str__(self) -> str: def __str__(self) -> str:

View File

@ -31,6 +31,7 @@ def send_mails(stage: EmailStage, *messages: list[EmailMultiAlternatives]):
autoretry_for=( autoretry_for=(
SMTPException, SMTPException,
ConnectionError, ConnectionError,
OSError,
), ),
retry_backoff=True, retry_backoff=True,
base=MonitoredTask, base=MonitoredTask,
@ -44,7 +45,7 @@ def send_mail(
self.set_uid(slugify(message_id.replace(".", "_").replace("@", "_"))) self.set_uid(slugify(message_id.replace(".", "_").replace("@", "_")))
try: try:
if not email_stage_pk: if not email_stage_pk:
stage: EmailStage = EmailStage() stage: EmailStage = EmailStage(use_global_settings=True)
else: else:
stage: EmailStage = EmailStage.objects.get(pk=email_stage_pk) stage: EmailStage = EmailStage.objects.get(pk=email_stage_pk)
backend = stage.backend backend = stage.backend