Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store attachments as a list #1611

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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