我使用Nodemailer和NodeJS收到错误。我尝试使用我的网站发送电子邮件,但是我遇到了问题,电子邮件已发送,但我的Gmail界面上的“来自”和“收件人”都有相同的电子邮件...
屏幕截图:http://glui.me/?i=g43rrwpgdy6voy5/2014-03-18_at_18.32_2x.png/
我的代码:
var contact = req.body.contact;
var compagny = contact.compagny;
var email = contact.email;
var object = contact.object;
var message = contact.message;
var to = 'myemail@gmail.com';
var transport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "myemail@gmail.com",
pass: "*********"
}
});
var options = {
from: email,
to: to,
subject: object,
text: "Société : "+compagny+"\nEmail : "+email+"\nMessage : "+message
}
transport.sendMail(options, function(error, response) {
if (error)
console.log(error);
else
res.redirect('/');
});
答案 0 :(得分:0)
这是一个愚蠢的错误吗?你不应该使用
var from = 'myemail@gmail.com';
而不是
var to = 'myemail@gmail.com';