【发布时间】:2017-02-15 08:58:11
【问题描述】:
我的目标是从 node.js 服务器直接发送一封电子邮件用户的电子邮件,我正在使用 Sendgrid 发送这些电子邮件。它有效,但问题是,它直接发送到垃圾邮件文件夹。这是我从 Sendgrid 网站复制的代码
const helper = require('sendgrid').mail;
const from_email = new helper.Email("testing2@gmail.com");
const to_email = new helper.Email(user.email)
const subject = "Reset your password on Hackathon Starter";
const content = new helper.Content("text/plain", `You are receiving this email because you (or someone else) have requested the reset of the password for your account.\n\n
Please click on the following link, or paste this into your browser to complete the process:\n\n
http://${req.headers.host}/reset/${token}\n\n
If you did not request this, please ignore this email and your password will remain unchanged.\n`);
const mail = new helper.Mail(from_email, subject, to_email, content);
const sg = require('sendgrid')('APIKEY');
const request = sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: mail.toJSON()
});
sg.API(request, function(error, response) {
console.log(response.statusCode);
console.log(response.body);
console.log(response.headers);
});
我需要满足哪些要求才能将其直接发送到用户的收件箱?
【问题讨论】: