如何防止SparkPost更改电子邮件中的网址?

时间:2016-05-27 21:40:27

标签: node.js sparkpost

我使用SparkPost从我的node.js app发送电子邮件。

但是,所有链接都会转换为网址,例如:http://go.sparkpostmail1.com/f/a/EgvUoS2LdGPzMx-AURKwZA~~/AABUGAA~/RgRZK0BSP0EIAGukLuGW3OxXA3NwY1gEAAAAAFkGc2hhcmVkQgoAAVK7SFdpNVEbUhFuaWNvbGFzQGR1cmFuZC5jaAlRBAAAAABEUWh0dHBzOi8vZGlzaGx5Lm1lbnUvZC9XYXNoaW5ndG9uL1JlZ2VudF9UaGFpL0Jhc2lsX0phZS81NjBmMzk5MmQ0YWUxNTAzMDBmZWZmMGIiLEcCe30

我试图像这样禁用“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!');
        }
    });

1 个答案:

答案 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

此特定示例包括选项键: https://github.com/SparkPost/node-sparkpost/blob/master/examples/transmissions/send_transmission_all_fields.js