Skip to content

Instantly share code, notes, and snippets.

@adamlj
Created January 23, 2014 10:53
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save adamlj/8576660 to your computer and use it in GitHub Desktop.
Save adamlj/8576660 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