【问题标题】:How to send templated email via SendGrid API v3?如何通过 SendGrid API v3 发送模板化电子邮件?
【发布时间】:2017-12-18 08:09:40
【问题描述】:

在他们的文档中,SendGrid 描述了要发送到 API 的 structure

{ "to": // list of emails
  "sub": // list of substitutions
  "filters": // template ID here
}

但它究竟应该如何与mail send 结构一起使用呢?

{ "personalizations": 'to' and 'subject' here
  "from": ...
  "content": ... }

模板文档也说:

如果您使用的是 Web API v3 邮件发送端点,您只需在 JSON 有效负载的 template_id 参数中设置模板 ID,即可指定要使用的事务模板。

“简单”。行。但那我的替代品将如何指定呢?

【问题讨论】:

    标签: sendgrid sendgrid-api-v3 sendgrid-templates


    【解决方案1】:

    好吧,下面是一个工作示例。这与 v3 文档不同。

    {
      "personalizations" : [ {
        "substitutions" : {
          ":name" : "John"
        },
        "subject" : "Hello from Java",
        "to" : [ {
          "email" : "john@example.com"
        } ]
      } ],
      "from" : {
        "email" : "john@example.com"
      },
      "template_id" : "11111111-1111-1111-1111-111111111111"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-30
      相关资源
      最近更新 更多