2
我在sparkpost仪表板中创建了模板。但是我面对的问题是,我无法通过进行api调用来发送“CC”或“BCC”。下面的代码片段将帮助您了解我正在尝试执行的操作。调用节点sparkpost API时在替代数据中发送“CC”和“BCC”
var SPARKPOST_KEY = "KEY"
var sparkpost = require('sparkpost');
var sparkclient = new sparkpost(SPARKPOST_KEY);
var req_opts = {
\t transmissionBody : {
\t \t content: {
\t \t \t template_id: 'order-confirmation',
\t \t \t from: '[email protected]',
\t \t subject: 'Order confirmation',
\t \t headers: {
\t \t \t "CC": "<[email protected]>"
\t \t }
\t \t },
\t \t substitution_data: {
\t \t \t "CC": "[email protected]",
\t \t \t "customer": "Aravind",
\t \t \t "order": 123532
\t \t },
\t \t recipients: [
\t \t {address: {email:'[email protected]'}},
\t \t {address: {email: '[email protected]'}}
\t ],
\t "return_path": "[email protected]",
\t }
};
sparkclient.transmissions.send(req_opts, function(err, res){
\t if(err){
\t \t console.log("ERROR");
\t \t console.log(err)
\t }else {
\t \t console.log(res.body);
\t \t console.log("Mail has been successfully sent");
\t }
});
似乎不适用于模板。其拍摄错误:“{ ”错误“:[ { ”message“:”必填字段丢失“, ”description“:”'content'中至少有一个'text'或'html'存在'', “code”:“1400” } ] }' –
您的模板需要在'content'内包含'text'或'html'部分。 – orval
为什么我需要什么时候不需要它? –