Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PandaWhoCodes/5728016660233cebb2156a478f09bedf to your computer and use it in GitHub Desktop.
Save PandaWhoCodes/5728016660233cebb2156a478f09bedf 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