Created
March 22, 2020 15:25
-
-
Save JustAyush/eab6e46933b3ac0e69f9ac85c05e444b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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