我使用SparkPost从我的node.js app发送电子邮件。
我试图像这样禁用“click_tracking”(请参阅下面的代码示例),但它仍然无效。有没有人有想法配置SparkPost“按原样”发送电子邮件?
var sparky = new SparkPost(process.env.SPARKPOST_API_KEY, {"open_tracking": false, "click_tracking": false});
sparky.transmissions.send({transmissionBody: transmissionBody}, function (err, res) {
if (err) {
console.log('Whoops! Something went wrong in sendEmail');
console.log(err);
} else {
console.log('sendEmail sent!');
}
});
答案 0 :(得分:6)
SparkPost
对象时,未设置打开和点击跟踪,通过transmissionBody
密钥在options
中完成,如下所示:
var SparkPost = require('sparkpost');
var sp = new SparkPost('<YOUR API KEY>');
sp.transmissions.send({
transmissionBody: {
options: {
open_tracking: false,
click_tracking: false
},
content: {
from: 'testing@sparkpostbox.com',
subject: 'Hello, World!',
html:'<html><body><p>Testing SparkPost - the world\'s most awesomest email service!</p></body></html>'
},
recipients: [
{address: '<YOUR EMAIL ADDRESS>'}
]
}
}, function(err, res) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
} else {
console.log('Woohoo! You just sent your first mailing!');
}
});
此外,您可以在此处查看使用node-sparkpost进行传输的示例: https://github.com/SparkPost/node-sparkpost/tree/master/examples/transmissions