Skip to content

Commit ca77a4f

Browse files
committed
Merge branch 'dev' into 'main'
chore: handle header in ses See merge request locker/maily!27
2 parents 8ca55ce + 08803fa commit ca77a4f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/maily/services/ses.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def start_message_with_headers(subject, from_address, to_address, reply_address)
6161
# Create a multipart/mixed parent container.
6262
msg = MIMEMultipart("mixed")
6363
# Add subject, from and to lines.
64-
msg["Subject"] = subject
64+
# Sanitize the subject to remove newlines and other problematic characters
65+
clean_subject = subject.replace('\n', ' ').replace('\r', ' ').strip()
66+
msg["Subject"] = clean_subject
6567
msg["From"] = from_address
6668
msg["To"] = to_address
6769
msg["Reply-To"] = reply_address
@@ -110,10 +112,9 @@ def ses_send_raw_email(self, from_address, to_address, subject, message_body, at
110112
return False
111113
except (ConnectionClosedError, SSLError):
112114
return None
113-
# TODO: Handle email.errors.HeaderWriteError: folded header contains newline
114-
115-
except email.errors.MessageError:
116-
return False
115+
# # Handle email.errors.HeaderWriteError: folded header contains newline
116+
# except email.errors.MessageError:
117+
# return False
117118
return True
118119

119120
def list_identities(self):

0 commit comments

Comments
 (0)