Skip to content

Commit

Permalink
Merge branch 'dev' into 'main'
Browse files Browse the repository at this point in the history
chore: Handle aws ssl error

See merge request locker/maily!21
  • Loading branch information
khaitranquang committed Jun 3, 2024
2 parents ae30173 + b2e9630 commit 5d4cecb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/maily/aws/ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from maily.aws import AWS
from maily.logger import logger
from email.mime.text import MIMEText
from botocore.exceptions import ClientError, ConnectionClosedError
from botocore.exceptions import ClientError, ConnectionClosedError, SSLError
from email.mime.multipart import MIMEMultipart
from maily.locker_api import store_reply_record
from email.mime.application import MIMEApplication
Expand Down Expand Up @@ -105,7 +105,7 @@ def ses_send_raw_email(self, from_address, to_address, subject, message_body, at
# logger.error(
# f'from_address: {from_address}\nto_address: {to_address}\ndata: {msg_with_attachments.as_string()}')
return False
except ConnectionClosedError:
except (ConnectionClosedError, SSLError):
return None
return True

Expand Down
4 changes: 2 additions & 2 deletions src/maily/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from urllib.request import urlopen
from maily.aws.s3 import s3_client
from maily.aws.ses import ses_client
from botocore.exceptions import ClientError
from botocore.exceptions import ClientError, ConnectionClosedError, SSLError
from email import message_from_bytes, policy
from django.utils.encoding import smart_bytes
from maily.exceptions import InReplyToNotFound
Expand Down Expand Up @@ -234,7 +234,7 @@ def get_text_html_attachments(self):
# we are returning a 500 so that SNS can retry the email processing
# return self.response(503, "Cannot fetch the message content from S3")
return self.response(504, "Fetch message from S3 error - boto3.ClientError")
except botocore.exceptions.ConnectionClosedError:
except (ConnectionClosedError, SSLError):
return self.response(504, "Fetch message from S3 error - boto3.ConnectionClosedError")
else:
message_content = self.sns_message_content
Expand Down

0 comments on commit 5d4cecb

Please sign in to comment.