Created
March 10, 2020 15:46
-
-
Save lionxcr/fa124e76730e66b632bed3debebe7a18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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