【发布时间】:2015-01-04 07:06:24
【问题描述】:
我正在尝试通过在我的 index.php 中构建 SendGrid X-SMTPAPI 标头来应用 sendgrid 模板。
这是我的 index.php 代码的摘要:
// Start Sendgrid
$sendgrid = new SendGrid('userid', 'pwd');
$header = new Smtpapi\Header();
$filter = array(
'templates' => array(
'settings' => array(
'enabled' => 1,
'template_id' => 'f2c99ace-87af-2618-8390-c19e2ad2805f'
)
)
);
$header->setFilters($filter);
$emailwelcome = new SendGrid\Email();
$emailwelcome->addTo($email)->
setFrom('hello@world.com')->
setFromName('Welcome to World')->
setSubject('Your Invitation')->
setText('Hello World!')->
setHtml('<strong>Hello World!</strong>');
$sendgrid->send($emailwelcome);
要应用从 SendGrid 文档中复制的模板:
"启用模板 要在发送时使用模板引擎模板,请启用模板过滤器并将 template_id 设置为您的模板引擎模板之一。
例子
{
"filters": {
"templates": {
"settings": {
"enable": 1,
"template_id": "5997fcf6-2b9f-484d-acd5-7e9a99f0dc1f"
}
}
}
}
您可以在 SMTP 消息的 X-SMTPAPI 标头中或在 mail.send API 调用的 x-smtpapi 参数中使用此 JSON。"
问题是... 我的 SMTP 消息的 X-SMTPAPI 标头在哪里? 在我的 composer.json 或 index.php 或供应商文件中?
感谢您的帮助。
【问题讨论】:
-
如果有帮助的话,有一些模板服务可以在 SendGrid 之上运行,例如 sendwithus.com 或 customer.io。根据您的用例,可能值得一试。
标签: php json email templates sendgrid