【发布时间】:2015-09-16 11:28:17
【问题描述】:
我一直在尝试 nodemailer。我被困。 它运行控制台日志,我没有收到任何错误或任何东西。 req.body 中填充了数据。
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport();
app.post('/contact-form', sendMail = function (req, res) {
transporter.sendMail({
from: 'req.body.contactEmail',
to: 'mymail@mail.com',
subject: 'Message from ' + req.body.contactEmail,
text: req.body.contactMsg + 'my contact information: ' + req.body.contactEmail + " " + req.body.contactNummer
}),function(error, response) {
if (error) {
console.log(error);
} else {
console.log("Message sent: " + response.message);
}
}
console.log(req.body.contactMsg);
});
【问题讨论】:
-
您在哪里设置传输参数?主机名、端口、身份验证等?
-
我使用的是直接运输。我想我应该使用 smtp 提供程序... 使用直接传输不可靠,因为默认情况下使用的传出端口 25 通常被阻止。此外,从动态地址发送的邮件通常被标记为垃圾邮件。您真的应该考虑使用 SMTP 提供程序。
标签: node.js smtp sendmail nodemailer