2

我正在使用 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

有任何想法吗?

问候,奥马尔。

4

0 回答 0