Skip to content

Instantly share code, notes, and snippets.

@abhinavlal
Created March 5, 2013 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhinavlal/5089348 to your computer and use it in GitHub Desktop.
Save abhinavlal/5089348 to your computer and use it in GitHub Desktop.
Requests send multiple file
WebOb==1.2.3
argparse==1.2.1
requests==0.7.5
wsgiref==0.1.2
import requests
from webob.multidict import MultiDict
r = requests.post(
"https://api.mailgun.net/v2/excited.net/messages",
auth=("api", "YOUR API KEY"),
files=MultiDict([("attachment", open("a.txt")),
("attachment", open("b.txt"))]),
data={"from": "Excited User <hello@excited.com>",
"to": "hello@superexcited.com",
"subject": "Hello",
"text": "Testing some Mailgun awesomness!",
"html": "<html>HTML version of the body</html>"})
print r.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment