Skip to content

Instantly share code, notes, and snippets.

@panacholn
Last active June 22, 2023 10:12
Show Gist options
  • Save panacholn/5bd09204eadae9845019e33657a75635 to your computer and use it in GitHub Desktop.
Save panacholn/5bd09204eadae9845019e33657a75635 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: 'yourmail@hotmail.com', // your email
pass: 'password' // your password
}
});
// setup email data with unicode symbols
const mailOptions = {
from: 'sender@hotmail.com', // sender
to: 'receiver@hotmail.com', // 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