thomas g thomas g -4 years ago 131
Node.js Question

Nodemailer does'nt work properly

The email comes from my e-mail address rather than the sender. Any ideas?

var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'mail',
pass: 'pass'
}
});

var mailOptions = {
from: req.body.email , // sender address
to: 'mail', // list of receivers
subject: ' ', // Subject line
text: req.body.message,
html: '<p>'+req.body.message+'</p>'// plain text body

};

Answer Source

This is how Gmail works. It won't let you to send emails as anyone but you, for security reasons.

If you need more flexibility then you should use a transactional email service like Mailgun, Mandrill or SendGrid - which you can easily use with Nodemailer (there are Nodemailer transports available for them, just like for Gmail).

See: https://www.npmjs.com/browse/keyword/nodemailer

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download