Skip to content

Commit

Permalink
Merge pull request #1611 from mozilla/attachments-as-list-1559
Browse files Browse the repository at this point in the history
Store attachments as a list
  • Loading branch information
say-yawn authored Mar 8, 2022
2 parents 0cb89ff + 56db6a3 commit c9f332e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion emails/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _add_body_to_message(msg, message_body):

def _add_attachments_to_message(msg, attachments):
# attach attachments
for actual_att_name, attachment in attachments.items():
for actual_att_name, attachment in attachments:
# Define the attachment part and encode it using MIMEApplication.
attachment.seek(0)
att = MIMEApplication(attachment.read())
Expand Down
4 changes: 2 additions & 2 deletions emails/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,15 +794,15 @@ def _get_attachment(part):
def _get_all_contents(email_message):
text_content = None
html_content = None
attachments = {}
attachments = []
if email_message.is_multipart():
for part in email_message.walk():
try:
if part.is_attachment():
att_name, att = (
_get_attachment(part)
)
attachments[att_name] = att
attachments.append((att_name, att))
continue
if part.get_content_type() == 'text/plain':
text_content = part.get_content()
Expand Down

0 comments on commit c9f332e

Please sign in to comment.