如何使用带有php api的SendGrid模板发送电子邮件?

Muc*_*Muc 5 php sendgrid

我最近在我的SendGrid帐户中创建了一个模板,我想在我的php应用程序中使用它.

我目前正在使用该帐户发送电子邮件,但我必须在我的应用程序内编码html,这不能提供我需要的灵活性.

我在API中找不到一个方法来选择我想要使用的模板并替换变量....

任何的想法?

谢谢

Adh*_*anx 5

在深入研究 GitHub 后,我发现这个代码片段对我有用......我希望它对你有帮助。要在 v3 中使用模板,代码如下:

$mail->setTemplateId("xxxxxxxxxxxxxxxxxxxx");
// Put your template ID in from the web console after you create a template
Run Code Online (Sandbox Code Playgroud)

  • 确认它在 2020 年仍然有效:)并且他们的文档仍然很糟糕:( (2认同)