0

使用 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('/');
    });
4

1 回答 1

0

这是一个愚蠢的错误吗?你不应该使用

 var from = 'myemail@gmail.com';

代替

 var to = 'myemail@gmail.com'; 

?

于 2014-03-18T18:35:13.153 回答