【发布时间】:2014-10-02 10:32:50
【问题描述】:
我使用 mailgun 发送邮件。 我尝试使用 python api
pwd = "path-to-image/logo.png"
return requests.post(
"https://api.mailgun.net/v2/sandboxsomething.mailgun.org/messages",
auth=("api", "key-something"),
files=[("inline", open(pwd)),],
data={"from": src,
"to": des,
"subject": sub,
"html": message})
但它无法发送图像。
之后,当我打印print open(pwd).read() 时,我尝试仅显示 png 文件:
�PNG
none
但是当我尝试print open('path-to-image/a.txt')时,我得到了文件内容:
all content of a.text
none
为什么没有读取png 文件?
【问题讨论】:
-
“它可以发送图像”是什么意思?它会产生错误消息吗?邮件发不出去吗?邮件是否已发送,但数据有误?
-
它发送消息,但图像不能显示,因为它是空的!。我尝试在发送之前打印图像,我得到
�PNG none。
标签: python mailgun inline-images