gpt4 book ai didi

javascript - 无法使用 NodeJs 使用新的 v3 Sendgrid API 发送电子邮件

转载 作者:搜寻专家 更新时间:2023-11-01 00:06:06 24 4
gpt4 key购买 nike

我正在尝试发送电子邮件,但发送失败。我在 README 上使用了您的示例,还使用了非 Helper 方法之一,但它们似乎都不起作用。

import { mail } from 'sendgrid';
const helper = mail;
const from_email = new helper.Email('admin@test.com');
const to_email = new helper.Email('someuser@test.com');
const subject = 'Testing';
const content = new helper.Content('text/plain', 'Test Description');
const email = new helper.Mail(from_email, subject, to_email, content);
const sg = require('sendgrid')(process.env.SENDGRID_API_KEY);
const request = sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: email.toJSON()
});
sg.API(request, function(error, response) {
console.log(response.statusCode);
console.log(response.body);
console.log(response.headers);
});

第一个console.log吐出202statusCode
第二个 console.log 什么也没吐出来。
最后一个 console.log 输出了这个:

 { 
server: 'nginx',
date: 'Mon, 15 Aug 2016 08:59:42 GMT',
'content-type': 'text/plain; charset=utf-8',
'content-length': '0',
connection: 'close',
'x-message-id': 'kQdayBbvSKSb9ZlVDCUKTg',
'x-frame-options': 'DENY'
}

最佳答案

对于遇到类似问题的任何人。

我的帐户显然已停用,因为我没有登录回答他们的支持查询。因此,您需要做的是联系他们的支持团队。

关于javascript - 无法使用 NodeJs 使用新的 v3 Sendgrid API 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38953871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com