【发布时间】:2017-09-16 14:06:59
【问题描述】:
我正在使用 nodemailer 来处理联系表格和邮寄事情。
但是当我尝试将 req.body.email 设置为 from: email 时,它只使用身份验证电子邮件。所以我收到的所有电子邮件都来自:me@me.com 到:me@me.com
而不是从:customer@them.com 到:me@me.com
我很确定我做得对
var mailOpts, smtpTrans;
//Setup Nodemailer transport, I chose gmail. Create an routerlication-specific password to avoid problems.
smtpTrans = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: "me@me.com",
pass: "hey"
}
});
//Mail options
console.log(req.body.email);
mailOpts = {
from: req.body.email, //grab form data from the request body object
to: 'me@me.com',
subject: 'Stockist interest form',
text: "Welcome to the My Leisure Stockists application process, we'd love to have you on board"+"\n Email: "+req.body.email
};
smtpTrans.sendMail(mailOpts, function (error, response) {
if (error) {
res.sendStatus(500);
} else {
res.sendStatus(200);
};
});
【问题讨论】:
-
我遇到了同样的问题。你有想过吗?还是这是预期的行为?
-
@MichaelLynch 不,实际上我仍在使用在 text: 属性中包含“电子邮件:”+req.body.email 的解决方案,以便我们可以通过电子邮件。我不认为这是预期的行为,因为我发誓,当我第一次安装 nodemailer 时,它的设置是从:电子邮件地址到 req.body.email 不再,我们应该提交错误报告
-
你现在明白了吗?我也有同样的问题。
-
即使我也有这个问题
-
我认为他们修复了它...一些方法,它现在可以工作了吗?
标签: node.js email smtp nodemailer