Skip to content

Instantly share code, notes, and snippets.

@jerryzhang222
Created February 24, 2017 01:09
Show Gist options
  • Save jerryzhang222/59f501558c387b618a08d5135980aea0 to your computer and use it in GitHub Desktop.
Save jerryzhang222/59f501558c387b618a08d5135980aea0 to your computer and use it in GitHub Desktop.
'use strict';
const nodemailer = require('nodemailer');
const smtpConfig = {
host: 'smarthost.yahoo.com',
port: 25,
secure: false, // upgrade later with STARTTLS
auth: {
user: 'jerryzhang@yahoo.com',
pass: 'pass'
}
};
// create reusable transporter object using the default SMTP transport
const transporter = nodemailer.createTransport({ smtpConfig });
// setup email data with unicode symbols
const mailOptions = {
from: '"Jerry Zhang" <jerryzhang@yahoo-inc.com>', // sender address
to: 'jerryzhang@yahoo-inc.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ?', // plain text body
html: '<b>Hello world ?</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
return [null, info.response];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment