V
V
Vyacheslav Lebedev2015-05-28 00:16:19
Node.js
Vyacheslav Lebedev, 2015-05-28 00:16:19

How to send a simple email using node?

Good evening!
Help me figure out how to send to gmail or yandex.
Tried with nodemailer, both 0.7.* version and latest.
Gives an error message.

var mailOptions, nodemailer, transporter;
nodemailer = require('nodemailer');
transporter = nodemailer.createTransport({
  service: 'Gmail',
  auth: {
    user: '[email protected]',
    pass: '***'
  }
});
mailOptions = {
  from: 'Slavik <[email protected]>',
  to: '',
  subject: 'Hello',
  html: '<b>test</b>'
};
transporter.sendMail(mailOptions, function(err, info) {
  if (err) {
    return console.log(err);
  }
  return console.log("Message sent: " + info.response);
});

Mistake:
{ [Error: No recipients defined] code: 'EENVELOPE' }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Shikanov, 2015-05-28
@slavikse

You have, as it were, the recipient (to) indicated by an empty string, and this is clearly written in the error message.

B
Boogie1989, 2016-05-31
@Boogie1989

I'm trying to run it myself, too, but it doesn't accept a password either. Did you succeed?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question