我的模板是
Hi %first_name%,
This is %section_var%
我的PHP代码是
$request_body = json_decode('{
"from": {
"email": "team@grassrootsapp.in",
"name": "Team Grassroots"
},
"mail_settings": {
"footer": {
"enable": false
}
},
"personalizations": [
{
"subject": "Accident Free Nation",
"to": [
{"email": "saiy2k@gmail.com"},
{"email": "team@grassrootsapp.in"}
],
"substitutions": {
"%first_name%": "Saiyasodharan"
},
"section": {
"%section_var%": "Section Text"
}
}],
"subject": "Hello, World!",
"template_id": "d6c26028-3765-461d-852e-43454115bc39"
}');
$response = $sg->client->mail()->send()->post($request_body);
上面的代码在某种程度上有效,我有很多问题
section
属性无效。 section
移到personalizations
之外,并将其放在文档中给出的sections
标记内。但要么没有效果,要么我得到Bad request
错误substitutions
,我需要传递一个数组,每个电子邮件ID的值都不同。但是,如果我将substitutions
更改为数组,则会导致Bad request
错误。设置属性sub
也没有帮助。看起来当前的文档和实际实现不同步。