Javascript Can';t使用NodeJs使用新的v3 Sendgrid API发送电子邮件
我正试图发送一封电子邮件,但无法通过。 我在自述中使用了您的示例,也使用了非助手方法1,但它们似乎都不起作用Javascript Can';t使用NodeJs使用新的v3 Sendgrid API发送电子邮件,javascript,node.js,api,email,sendgrid,Javascript,Node.js,Api,Email,Sendgrid,我正试图发送一封电子邮件,但无法通过。 我在自述中使用了您的示例,也使用了非助手方法1,但它们似乎都不起作用 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'; con
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);
});
第一个控制台.log
弹出202
的statusCode
第二个
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'
}
适用于任何有类似问题的人。
我的帐户显然已停用,因为我没有登录回答他们的支持查询。所以你需要做的是联系他们的支持团队 你找到原因了吗?