我正在尝试使用 v3 API 通过 Sendgrid 发送电子邮件,我想传递与此类似的 json 数据
{
"personalizations": [
{
"to": [
{
"email": "john.doe@example.com",
"name": "John Doe"
}
],
"subject": "Hello, World!"
}
],
"from": {
"email": "sam.smith@example.com",
"name": "Sam Smith"
},
"reply_to": {
"email": "sam.smith@example.com",
"name": "Sam Smith"
}
}
我的代码:
$email_content = [
'personalizations' => [
'to' => [
'email' => 'ashuomble5@gmail.com',
'name' => 'Ashutosh'
],
'subject' => 'Test'
],
'from' => [
'email' => 'ashuomble5@gmail.com',
'name' => 'Ashu'
],
'reply_to' => [
'email' => 'ashuomble5@gmail.com',
'name' => 'AO'
],
'content' => [
'type' => 'text/plain',
'value' => 'Hello'
]
];
json_encode() 输出后格式如下:
{
"personalizations":{
"to":{
"email":"ashuomble5@gmail.com",
"name":"Ashutosh"
},
"subject":"Test"
},
"from":{
"email":"ashuomble5@gmail.com",
"name":"Ashu"
},
"reply_to":{
"email":"ashuomble5@gmail.com",
"name":"AO"
},
"content":{
"type":"text\/plain",
"value":"Hello"
}
}
任何帮助将不胜感激。出于特定原因,我只想使用 v3 API