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