Mailgun sends inline images but no text. [Python+Mailgun-Api]


I'm using the python mailgun-api to send an email with an image, the email and the image arrive to the recipient with no problems, but the text i send in the "text": "Testing some Mailgun awesomness!" it doesn't, it outputs as body text the "html": '<html>HTML version of the body</html>' part.

data={"from": "Excited User <[email protected]>",
      "to": "[email protected]",
      "subject": "Hello",
      "text": "Testing some Mailgun awesomness!",
      "html": '<html>Inline image here: <img src="cid:test.jpg"></html>'})

How I can fix this?, of course if I add in the html line the text I want, it looks OK but I don't know if it is the correct way to do it. Should I use as body text the "html" part and remove the "text" part?

Thank you


First, note that the User's Manual has a bug. The correct code snippet should look like this:

def send_simple_message():
        auth=("api", "YOUR-KEY"),
        files={"inline":("image", open("/tmp/image.jpg"))},
        data={"from": "[email protected]",
              "to": ["[email protected]"],
              "subject": "Hello",
              "text": "Testing some Mailgun awesomness!",
              "html": '
By : Robᵩ

This video can help you solving your question :)
By: admin