I have templates created in SparkPost dashboard. But the problem I face is that I am not able to send "CC" or "BCC" by making the api calls. The code snippet below will help you understand what I am trying to do.
var SPARKPOST_KEY = "KEY"
var sparkpost = require('sparkpost');
var sparkclient = new sparkpost(SPARKPOST_KEY);
var req_opts = {
transmissionBody : {
content: {
template_id: 'order-confirmation',
from: '[email protected]',
subject: 'Order confirmation',
headers: {
"CC": "<[email protected]>"
}
},
substitution_data: {
"CC": "[email protected]",
"customer": "Aravind",
"order": 123532
},
recipients: [
{address: {email:'[email protected]'}},
{address: {email: '[email protected]'}}
],
"return_path": "[email protected]",
}
};
sparkclient.transmissions.send(req_opts, function(err, res){
if(err){
console.log("ERROR");
console.log(err)
}else {
console.log(res.body);
console.log("Mail has been successfully sent");
}
});