Skip to content

Commit 281c2b9

Browse files
committed
ee
1 parent 709531a commit 281c2b9

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

backend/notifications/tasks.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from celery.exceptions import MaxRetriesExceededError
22
import logging
3-
import smtplib
43
from uuid import uuid4
54
from notifications.models import SentEmail
6-
from django.db import transaction
75
from pycon.celery import app
86
from django.core.mail import EmailMultiAlternatives
97
from django.core.mail import get_connection
@@ -16,7 +14,6 @@
1614
retry_backoff=5,
1715
max_retries=5,
1816
)
19-
@transaction.atomic()
2017
def send_pending_email(self, sent_email_id: int):
2118
logger.info(
2219
"Sending sent_email=%s (retry=%s of %s)",
@@ -40,7 +37,13 @@ def send_pending_email(self, sent_email_id: int):
4037

4138
message_id = send_email(sent_email, email_backend_connection)
4239
sent_email.mark_as_sent(message_id)
43-
except smtplib.SMTPException as e:
40+
41+
logger.info(
42+
"Email sent_email_id=%s sent with message_id=%s",
43+
sent_email.id,
44+
message_id,
45+
)
46+
except Exception as e:
4447
try:
4548
self.retry(e)
4649
except MaxRetriesExceededError:
@@ -50,19 +53,6 @@ def send_pending_email(self, sent_email_id: int):
5053
sent_email.id,
5154
)
5255
return
53-
except Exception as e:
54-
sent_email.mark_as_failed()
55-
logger.error(
56-
"Failed to send email sent_email_id=%s",
57-
sent_email.id,
58-
)
59-
raise e
60-
61-
logger.info(
62-
"Email sent_email_id=%s sent with message_id=%s",
63-
sent_email.id,
64-
message_id,
65-
)
6656

6757

6858
def send_email(sent_email, email_backend_connection):

0 commit comments

Comments
 (0)