【问题标题】:Can't send emails with the new v3 Sendgrid API using NodeJs无法使用 NodeJs 使用新的 v3 Sendgrid API 发送电子邮件
【发布时间】:2016-08-15 11:03:51
【问题描述】:

我正在尝试发送一封电子邮件,但它没有通过。 我在 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 吐出statusCode202
第二个 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 node.js api email sendgrid


【解决方案1】:

对于任何有类似问题的人。

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

【讨论】:

    猜你喜欢
    • 2019-06-14
    • 1970-01-01
    • 2021-10-23
    • 1970-01-01
    • 2021-04-13
    • 2020-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多