I'm using python requests to post a request. when the attachment parameter has some non ascii characters an exception is raised, in other occasions where only ascii data exists, everything is fine.
you can see the exception here
response = requests.post(url="https://api.mailgun.net/v2/%s/messages" % utils.config.mailDomain,
auth=("api", utils.config.mailApiKey),
data={
"from" : me,
"to" : recepients,
"subject" : subject,
"html" if html else "text" : message
},
files= [('attachment', codecs.open(f.decode('utf8'))) for f in attachments] if attachments and len(attachments) else []
)
EDITS: After decoding the file name with utf8, I don't get an exception however the file is not attached. I debugged requests with attaching a file with only ascii characters in its name, and the request headers requests build is:
{'Content-Type': None, 'Content-Location': None, 'Content-Disposition': u'form-data; name="attachment"; filename="Hello.docx"'}
This succeeds, I'm getting the mail with the attachments.
However, when using a file with Hebrew characters, the request's header is:
{'Content-Type': None, 'Content-Location': None, 'Content-Disposition': 'form-data; name="attachment"; filename*=utf-8\'\'%D7%91%D7%93%D7%99%D7%A7%D7%94.doc'}
I get the mail but without the file attached to it. Any ideas?