Skip to content

Instantly share code, notes, and snippets.

@mcroni
Forked from adamlj/send_mailgun_attachments.py
Created August 18, 2019 23:08
Show Gist options
  • Save mcroni/083c521e23785ef87166886ee6c79d2a to your computer and use it in GitHub Desktop.
Save mcroni/083c521e23785ef87166886ee6c79d2a to your computer and use it in GitHub Desktop.
MailGun API Python Requests multiple Attachments Send mail with multiple files/attachments with custom file names
requests.post("https://api.mailgun.net/v2/DOMAIN/messages",
auth=("api", "key-SECRET"),
files={
"attachment[0]": ("FileName1.ext", open(FILE_PATH_1, 'rb')),
"attachment[1]": ("FileName2.ext", open(FILE_PATH_2, 'rb'))
},
data={"from": "FROM_EMAIL",
"to": [TO_EMAIL],
"subject": SUBJECT,
"html": HTML_CONTENT
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment