cc和bcc无法尝试使用Web_API_v3发送邮件

时间:2016-07-27 13:15:23

标签: node.js api sendgrid

我尝试使用" 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!"}]}'

1 个答案:

答案 0 :(得分:0)

您的JSON对于此用例不正确。您正在关闭“to”对象后面的个性化对象,它还应包含ccbcc对象。

Here's an example

{
  "personalizations": [{
      "to": [{
          "email": "recipient1@example.com"
      }],
      "cc": [{
          "email": "recipient2@example.com"
      }],
      "bcc": [{
          "email": "recipient3@example.com"
      }]
  }]
}

您也可以将subject置于个性化设置中,但不能fromcontent-type

相关问题