documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Python inline images

Open aayaffe opened this issue 7 years ago • 0 comments

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>'})

aayaffe avatar Aug 30 '17 19:08 aayaffe