如何在Sendgrid v3中添加CC收件人?
问题描述:
您好,我需要在PHP中使用sendgrid v3 API添加其他“cc”收件人。我该怎么做?如何在Sendgrid v3中添加CC收件人?
在文档中他们提供了下面的代码,但我觉得它不够,因为我需要看看如何添加“CC”收件人。
$request_body = json_decode('{
"personalizations": [
{
"to": [
{
"email": "[email protected]"
}
],
"subject": "Hello World from the SendGrid PHP Library!"
}
],
"from": {
"email": "[email protected]"
},
"content": [
{
"type": "text/plain",
"value": "Hello, Email!"
}
]
}'
);
答
努力和搜索想疯了后,我找到了答案:
$request_body = json_decode('{ "personalizations": [
{
"to": [
{
"email": "[email protected]"
}
],
"cc":[
{
"email": "[email protected]"
}],
"subject": "Hello world"
}
],
"from": {
"email": "[email protected]"
},"content": [
{
"type": "text/html",
"value": "<strong>Hello</strong>, Email!"
}]}');
向下滚动到要求的身体参数和阅读文档:https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail /index.html – silentsod