documentation
documentation copied to clipboard
Python inline images
Python inline images documentation code example has an error:
add "rb" to open method in files=[("inline", open("files/test.jpg"))],
This code snippet:
def send_inline_image():
return requests.post(
"https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages",
auth=("api", "YOUR_API_KEY"),
files=[("inline", open("files/test.jpg"))],
data={"from": "Excited User <YOU@YOUR_DOMAIN_NAME>",
"to": "[email protected]",
"subject": "Hello",
"text": "Testing some Mailgun awesomness!",
"html": '<html>Inline image here: <img src="cid:test.jpg"></html>'})
should change to:
def send_inline_image():
return requests.post(
"https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages",
auth=("api", "YOUR_API_KEY"),
files=[("inline", open("files/test.jpg","rb"))],
data={"from": "Excited User <YOU@YOUR_DOMAIN_NAME>",
"to": "[email protected]",
"subject": "Hello",
"text": "Testing some Mailgun awesomness!",
"html": '<html>Inline image here: <img src="cid:test.jpg"></html>'})