我想通过带有 curl post 的 Sparkpost API 发送附有 pdf 文件的电子邮件。
插入我使用的 pdf(我的 test.pdf 约为 200KB)
"data":"'$(cat test.pdf} | base64 --wrap=0)'"
但不知何故,这不起作用显示以下错误:
/usr/bin/curl: Die Argumentliste ist zu lang (original)
/usr/bin/curl: Argument list is too long
编辑:卷曲命令
curl -X POST https://api.eu.sparkpost.com/api/v1/transmissions -H 'Authorization: <APIKEY>' -H 'Content-Type: application/json' -d '{
"options":{
"open_tracking":false,
"click_tracking":false,
"inline_css":false
},
"recipients":[
{
"address":{
"email":"user@domain.tld",
"name":"user"
}
}
],
"content":{
"from":{
"name":"sender",
"email":"sender@domain.tld"
},
"reply_to":"replyto@domain.tld",
"subject":"subject",
"text":"textbody",
"attachments":[
{
"name":"attachmentname.pdf",
"type":"application/pdf",
"data":"'$(cat test.pdf | base64 --wrap=0)'"
}
]
}
}'