Sendgrid sent_at nodejs

时间:2015-11-20 07:33:53

标签: node.js api email sendgrid

我遇到的问题是我使用https://github.com/sendgrid/sendgrid-nodejs通过API发送电子邮件,每次我使用sent_at函数时,我的电子邮件在我的Sendgrid仪表板中都有类型:“Drop”,原因是:“无效的SMTPAPI标头”。我真的找不到原因......这是我的代码:

var email = new sendgrid.Email({
  to:       "test@myemail.com",
  from:     "me@noreply.com",
  subject:  "TEST"
});

var now = moment();
now.add(4, 'days');
email.setSendAt(now.unix());

sendgrid.send(email, function(err, json) {
  if (err) { return callback(err); }
  console.log("json email promo response ->", json);
  return res.status(200).end();
});

我正在尝试安排我的电子邮件在4天后发送。当我执行此操作时,我收到“json email promo response - > success”。因此,外翻似乎运作良好。但是当我使用Sendgrid进入仪表板时,它不会处理我的电子邮件。

非常感谢! 亨利

1 个答案:

答案 0 :(得分:0)

您好我试图通过smtp api header validator来修复标题。这是一个非常有用的解析器。

当我把它说成无效的JSON:

{ to: "test@myemail.com", from: "me@noreply.com", subject: "TEST" }

但是解析器以这种方式验证了它:

{ "to": [ "test@myemail.com" ], "from": "me@noreply.com", "subject": "TEST" }

我必须为"to"的值创建一个数组,并在键周围添加了双引号。 希望这会对你有所帮助。