Skip to content

Instantly share code, notes, and snippets.

@lionxcr
Created March 10, 2020 15:46
Show Gist options
  • Save lionxcr/fa124e76730e66b632bed3debebe7a18 to your computer and use it in GitHub Desktop.
Save lionxcr/fa124e76730e66b632bed3debebe7a18 to your computer and use it in GitHub Desktop.
const nodemailer = require('nodemailer');
const mailOptions = {
from: FROM,
to: TO,
subject: SUBJECT,
html: EMAIL_TEMPLATE
};
await sendMail(mailOptions);
const sendMail = (mailOptions) => new Promise((resolve, reject) => {
const transporter = nodemailer.createTransport({
service: 'GMAIL',
host: 'SMTPOUT',
secureConnection: true,
port: 465,
auth: {
user: 'EMAIL',
pass: 'PASS'
}
});
transporter.sendMail(mailOptions, function (error, result) {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment