Skip to content

Instantly share code, notes, and snippets.

@JustAyush
Created March 22, 2020 15:25
Show Gist options
  • Save JustAyush/eab6e46933b3ac0e69f9ac85c05e444b to your computer and use it in GitHub Desktop.
Save JustAyush/eab6e46933b3ac0e69f9ac85c05e444b to your computer and use it in GitHub Desktop.
// Local Imports
const nodemailer = require("nodemailer");
async function sendEmail(email, subject, body) {
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 587,
secure: false,
auth: {
user: "[email protected]",
pass: "--------------------------------PUT PASSWORD HERE------------------------------------------------"
}
});
let info = await transporter.sendMail({
from: '"RoomMate" <[email protected]>',
to: email,
subject: subject,
html: body,
});
console.log("Message sent: %s", info.messageId);
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
}
module.exports = {
sendEmail
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment