Node.js SendGrid电子邮件传递状态API

Node.js SendGrid电子邮件传递状态API,node.js,sendgrid,sendgrid-api-v3,Node.js,Sendgrid,Sendgrid Api V3,我目前正在使用Node.js的SendGrid电子邮件API,使用GitHub上的示例代码发送电子邮件 const sgMail = require('@sendgrid/mail'); sgMail.setApiKey(process.env.SENDGRID_API_KEY); const msg = { to: 'test@example.com', from: 'test@example.com', subject: 'Sending with Twilio SendGrid

我目前正在使用Node.js的SendGrid电子邮件API,使用GitHub上的示例代码发送电子邮件

const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
  to: 'test@example.com',
  from: 'test@example.com',
  subject: 'Sending with Twilio SendGrid is Fun',
  text: 'and easy to do anywhere, even with Node.js',
  html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);
const sgMail=require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID\u API\u KEY);
常数msg={
致:'test@example.com',
发件人:'test@example.com',
主题:“用Twilio SendGrid发送很有趣”,
text:'在任何地方都很容易,即使使用Node.js',
html:“并且在任何地方都可以轻松操作,即使使用Node.js”,
};
sgMail.send(msg);
我希望能够在我的应用程序中显示此电子邮件的传递状态。 使用SendGrid API是否可以做到这一点?如果可以,我应该如何做到


谢谢你

我不确定你是否在找这个,但是他们有电子邮件活动API,你必须单独订阅。

var http=require(“https”);
变量选项={
“方法”:“获取”,
“主机名”:“api.sendgrid.com”,
“端口”:空,
“路径”:“/v3/messages?query=status=“已处理”和to_email=“”,
“标题”:{
“授权”:“持票人”
}
};
var req=http.request(选项、函数(res){
var chunks=[];
res.on(“数据”,函数(块){
推(chunk);
});
res.on(“结束”,函数(){
var body=Buffer.concat(块);
console.log(body.toString());
});
});
请求写入(“{}”);
请求结束();
此外,请选中此项进行计算查询:

一些电子邮件活动:

我不确定您是否正在寻找此应用程序,但他们有电子邮件活动API,您必须单独订阅。

var http=require(“https”);
变量选项={
“方法”:“获取”,
“主机名”:“api.sendgrid.com”,
“端口”:空,
“路径”:“/v3/messages?query=status=“已处理”和to_email=“”,
“标题”:{
“授权”:“持票人”
}
};
var req=http.request(选项、函数(res){
var chunks=[];
res.on(“数据”,函数(块){
推(chunk);
});
res.on(“结束”,函数(){
var body=Buffer.concat(块);
console.log(body.toString());
});
});
请求写入(“{}”);
请求结束();
此外,请选中此项进行计算查询:

一些电子邮件活动:

Sendgrid具有Webhook,可以使用诸如已交付或延迟等信息更新您的应用程序。下面是一个链接
也可以在这里查看sendgrid可以向您发送的不同响应

sendgrid有Webhook,可以使用已交付或延迟等信息更新您的应用程序。下面是一个链接
在这里也可以找到sendgrid可以发送给您的不同回复

太好了,谢谢!是否可以使用此方法检查特定邮件的传递状态?谢谢,我想是的。看到这个@TomCoomer了吗?很好,谢谢!是否可以使用此方法检查特定邮件的传递状态?谢谢,我想是的。看到这个@TomCoomer,它满足你的要求了吗?
var http = require("https");

var options = {
  "method": "GET",
  "hostname": "api.sendgrid.com",
  "port": null,
  "path": "/v3/messages?query=status="processed" AND to_email="<<email>>"",
  "headers": {
    "authorization": "Bearer <<YOUR_API_KEY_HERE>>"
  }
};

    var req = http.request(options, function (res) {
      var chunks = [];

      res.on("data", function (chunk) {
        chunks.push(chunk);
      });

      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });

    req.write("{}");
    req.end();