Skip to content

Commit

Permalink
Pass-through email attachment content-id (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w authored Jan 6, 2019
1 parent 265ca25 commit 5f3b036
Show file tree
Hide file tree
Showing 4 changed files with 899 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describes an email, using the following schema:
"from": "email",
"subject": "string",
"body": "html",
"attachments": [{"filename": "string", "content": "base64"}]
"attachments": [{"filename": "string", "content": "base64", "id": "string"}]
}
-----------------
Expand Down
6 changes: 5 additions & 1 deletion opwen_email_server/utils/email_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ def _parse_attachments(mailparts: Iterable[MailPart]) -> Iterable[dict]:
for part in attachment_parts:
filename = part.sanitized_filename
payload = part.get_payload()
attachment_id = part.content_id
if filename and payload:
yield {'filename': filename, 'content': payload}
attachment = {'filename': filename, 'content': payload}
if attachment_id:
attachment['id'] = attachment_id
yield attachment


def _parse_addresses(message: PyzMessage, address_type: str) -> List[str]:
Expand Down
Loading

0 comments on commit 5f3b036

Please sign in to comment.