我目前正在使用带有Node.js的SendGrid电子邮件API,以在GitHub上使用其示例代码发送电子邮件。
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: '[email protected]',
from: '[email protected]',
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);
我希望能够在我的应用程序中显示此电子邮件的传递状态。使用SendGrid API是否可以实现,如果可以,我应该怎么做?
谢谢
我不确定您是否正在寻找它,但是他们有电子邮件活动API,您必须单独订阅。email activity
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();
[另外,请检查以下内容以进行综合查询:https://sendgrid.com/docs/for-developers/sending-email/getting-started-email-activity-api/