Preserve filename of inline attachments

For ESPs that support both content-id and filename,
don't drop the filename.
This commit is contained in:
medmunds
2016-03-11 10:07:13 -08:00
parent 6214fbbdcd
commit b407e9f452
3 changed files with 21 additions and 9 deletions

View File

@@ -118,10 +118,15 @@ class MandrillPayload(RequestsPayload):
self.data["message"]["html"] = body
def add_attachment(self, attachment):
key = "images" if attachment.inline else "attachments"
self.data["message"].setdefault(key, []).append({
if attachment.inline:
field = "images"
name = attachment.cid
else:
field = "attachments"
name = attachment.name or ""
self.data["message"].setdefault(field, []).append({
"type": attachment.mimetype,
"name": attachment.name or "",
"name": name,
"content": attachment.b64content
})