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

3

我正在尝试发送一封邮件,但是它没有被送出。我使用了你在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' 
}

你弄清楚原因了吗? - James111
1个回答

0

对于遇到类似问题的人。

我的账户显然因为我没有登录回答他们的支持查询而被停用了。所以你需要做的是联系他们的支持团队。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接