我正在使用python 2.7和请求 这取自mailgun的文档:
def send_inline_image():
return requests.post(
"https://api.mailgun.net/v2/samples.mailgun.org/messages",
auth=("api", "key-3ax6xnjp29jd6fds4gc373sgvjxteol0"),
files=MultiDict([("inline", open("files/test.jpg"))]),
data={"from": "Excited User <me@samples.mailgun.org>",
"to": "sergeyo@profista.com",
"subject": "Hello",
"text": "Testing some Mailgun awesomness!",
"html": '<html>Inline image here: <img src="cid:test.jpg"></html>'})
当尝试按照描述发送附件时,我收到以下错误:
files=MultiDict([("inline", open("embeddedImages/bg.png"))])
File "build\bdist.win32\egg\requests\api.py", line 87, in post
File "build\bdist.win32\egg\requests\safe_mode.py", line 37, in wrapped
File "build\bdist.win32\egg\requests\api.py", line 42, in request
File "build\bdist.win32\egg\requests\sessions.py", line 230, in request
File "build\bdist.win32\egg\requests\models.py", line 507, in send
File "build\bdist.win32\egg\requests\models.py", line 366, in _encode_files
File "build\bdist.win32\egg\requests\packages\urllib3\filepost.py", line 80, i
n encode_multipart_formdata
TypeError: 'list' does not have the buffer interface
有什么想法吗?
此致 奥马尔。