2017-12-18 279 views
0

在他們的文檔SendGrid描述structure被髮送到API:如何通過SendGrid API v3發送模板化電子郵件?

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

但究竟是否應該與mail send結構一起使用嗎?

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

而且模板醫生說:

如果您在使用Web API V3郵件發送終端,你可以指定你想通過在設置模板ID只使用其中的交易模板您的JSON負載的template_id參數。

「簡單」。好。但是,我的替代品如何指定呢?

回答

0

那麼,下面是一個工作示例。這與v3文檔不同。

{ 
    "personalizations" : [ { 
    "substitutions" : { 
     ":name" : "John" 
    }, 
    "subject" : "Hello from Java", 
    "to" : [ { 
     "email" : "[email protected]" 
    } ] 
    } ], 
    "from" : { 
    "email" : "[email protected]" 
    }, 
    "template_id" : "11111111-1111-1111-1111-111111111111" 
} 
相關問題