Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kumpon-Sotsukpiam/7ccbbfbd2a9723ca47501fced74758a7 to your computer and use it in GitHub Desktop.
Save Kumpon-Sotsukpiam/7ccbbfbd2a9723ca47501fced74758a7 to your computer and use it in GitHub Desktop.
Nodemailer Example
// main.js
const nodemailer = require('nodemailer');
// setup mail transporter service
const transporter = nodemailer.createTransport({
service: 'hotmail',
auth: {
user: '[email protected]', // your email
pass: 'password' // your password
}
});
// setup email data with unicode symbols
const mailOptions = {
from: '[email protected]', // sender
to: '[email protected]', // list of receivers
subject: 'Hello from sender', // Mail subject
html: '<b>Do you receive this mail?</b>' // HTML body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function (err, info) {
if(err)
console.log(err)
else
console.log(info);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment