(Since Mailgun does not have a python library, this applies to both CURL and Python)
We are working on an isolated server without access to the file system.
This is an example provided by mailgun:
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 <me@samples.mailgun.org>",
"to": "foo@example.com",
"cc": "baz@example.com",
"bcc": "bar@example.com",
"subject": "Hello",
"text": "Testing some Mailgun awesomness!",
"html": "<html>HTML version of the body</html>"})
As you can see, the file name is only implied by open () calls.
Given that we do not have access to the file system, we download files from a remote location and transfer data.
This sends data to the mail, but the file names are ignored, making it almost impossible for clients to open files, as they had to guess the file extension for each attachment.
How do we specify file names manually?
Thank!
source
share