Skip to content

Instantly share code, notes, and snippets.

@svngoku
Created December 29, 2018 00:30
Show Gist options
  • Select an option

  • Save svngoku/b84264772203e74130969efcc12a7d1d to your computer and use it in GitHub Desktop.

Select an option

Save svngoku/b84264772203e74130969efcc12a7d1d to your computer and use it in GitHub Desktop.
SendMail πŸ“§ created by svngoku - https://repl.it/@svngoku/SendMail
/* Send mail With NodeJS */
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'youremail@gmail.com',
pass: 'yourpassword'
}
});
var mailOptions = {
from: 'youremail@gmail.com',
to: 'myfriend@yahoo.com',
subject: 'Sending Email using Node.js',
text: 'That was easy!'
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error);
} else {
console.log(`Email sent: ${info.response}`);
}
});
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"nodemailer": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-5.0.0.tgz",
"integrity": "sha512-XI4PI5L7GYcJyHkPcHlvPyRrYohNYBNRNbt1tU8PXNU3E1ADJC84a13V0vbL9AM431OP+ETacaGXAF8fGn1JvA=="
}
}
}
{
"main": "index.js",
"dependencies": {
"nodemailer": "5.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment