1
votes

the problem that I have is that I'm using https://github.com/sendgrid/sendgrid-nodejs to send email through the API and everytime I use the sent_at function, my email has the type : "Drop" in my Sendgrid Dashboard and the reason is : "invalid SMTPAPI header". I really can't find why... Here's my code :

var email = new sendgrid.Email({
  to:       "[email protected]",
  from:     "[email protected]",
  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();
});

I'm trying to schedule my email to be sent 4 days later. When I execute this, I receive the "json email promo response -> success". So everthing seems to work well. But when I go in my dashboard with Sendgrid, it doesn't process my email.

Thank you very much! Thierry

1

1 Answers

0
votes

Hi I tried to fix your header thanks to smtp api header validator . It's a really helpful parser.

When I put this it says invalid JSON :

{ to: "[email protected]", from: "[email protected]", subject: "TEST" }

But it's validated by the parser this way :

{ "to": [ "[email protected]" ], "from": "[email protected]", "subject": "TEST" }

I had to create an array for "to"'s value, and I added double quotes around keys. Hope this helps you.