我使用SparkPost从node.js应用程序发送电子邮件。
但是,所有链接都转换为URL,例如:http://go.sparkpostmail1.com/f/a/EgvUoS2LdGPzMx-AURKwZA~~/AABUGAA~/RgRZK0BSP0EIAGukLuGW3OxXA3NwY1gEAAAAAFkGc2hhcmVkQgoAAVK7SFdpNVEbUhFuaWNvbGFzQGR1cmFuZC5jaAlRBAAAAABEUWh0dHBzOi8vZGlzaGx5Lm1lbnUvZC9XYXNoaW5ndG9uL1JlZ2VudF9UaGFpL0Jhc2lsX0phZS81NjBmMzk5MmQ0YWUxNTAzMDBmZWZmMGIiLEcCe30
我试过像这样禁用“点击追踪”(见下面的代码示例),但它仍然不起作用。是否有人想将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!');
        }
    });

最佳答案

在实例化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: '[email protected]',
      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

07-24 18:42