Sending Email from Gmail via NodeJS

Published on 2019-03-07 by Mohd

Works fairly well!


var email = require('emailjs');

var server = email.server.connect({
  user: 'your_email_address@gmail.com',
  password: 'email_password',
  host: 'smtp.gmail.com',
  ssl: true
});

function sendMail(msg) {
  server.send({
    text: msg.text,
    from: 'your_email_address@gmail.com',
    to: 'your_personal_email_address@host.com',
    cc: '',
    subject: msg.from + ' just sent you a new notification'
  }, function (err, message) {
    console.log(err || message);
  });
}