title: How to send a mail with multiple attachments and custom file names using Mailgun (from Python)
body: <p>(As Mailgun doesn't have a python library this applies for both CURL and Python)</p>
  
  <p>We are working on a sandboxed server without access to the filesystem.</p>
  
  <p>This is the example provided by mailgun:</p>
  
  <pre><code>def send_complex_message():
      return requests.post(
          "https://api.mailgun.net/v2/samples.mailgun.org/messages",
          auth=("api", "key-3ax6xnjp29jd6fds4gc373sgvjxteol0"),
          files=[("attachment", open("files/test.jpg")),
                 ("attachment", open("files/test.txt"))],
          data={"from": "Excited User &lt;me@samples.mailgun.org&gt;",
                "to": "foo@example.com",
                "cc": "baz@example.com",
                "bcc": "bar@example.com",
                "subject": "Hello",
                "text": "Testing some Mailgun awesomness!",
                "html": "&lt;html&gt;HTML version of the body&lt;/html&gt;"})
  </code></pre>
  
  <p>As you can see the filename is only implied on the open() calls.</p>
  
  <p>Given that we have no access to the filesystem, we download the files from a remote location and pass the data.</p>
  
  <p>This sends the data in the mail but the filenames are ignored, this makes it almost impossible for clients to open the files as they would have to guess the file extension for every attachment.</p>
  
  <p>How do we specify the filenames manually?</p>
  
  <p>Thanks!</p>