我尝试使用" cc"发送电子邮件和" bcc"使用API请求
POST https://api.sendgrid.com/v3/mail/send HTTP/1.1
。
我收到了这样的错误
{"errors":[{"message":"The to array is required for all personalization objects, and must have at least one email object with a valid email address.","field":"personalizations.1.to","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.personalizations.to"},{"message":"The to array is required for all personalization objects, and must have at least one email object with a valid email address.","field":"personalizations.2.to"}]}
使用像这样的数据部分
--data '{"personalizations": [{"to": [{"email": "example@email.com"}]},{"cc": [{"email": "example@email.com"}]},{"bcc": [{"email": "example@email.com"}]}],"from": {"email": "example@email.com"},"subject": "Hello, World!","content": [{"type": "text/plain", "value": "Heya!"}]}'
答案 0 :(得分:0)
您的JSON对于此用例不正确。您正在关闭“to”对象后面的个性化对象,它还应包含cc
和bcc
对象。
{
"personalizations": [{
"to": [{
"email": "recipient1@example.com"
}],
"cc": [{
"email": "recipient2@example.com"
}],
"bcc": [{
"email": "recipient3@example.com"
}]
}]
}
您也可以将subject
置于个性化设置中,但不能from
或content-type
。