litebb/email.js

1const nodemailer = require("nodemailer"); 2 3const config = require("./config/config"); 4 5const transporter = nodemailer.createTransport({ 6 host: config.smtp.host, 7 port: config.smtp.port, 8 secure: true, // true for port 465, false for other ports 9 auth: { 10 user: config.smtp.username, 11 pass: config.smtp.password, 12 }, 13}); 14 15const sendEmail = async ({ to, subject, text, html }) => { 16 return transporter.sendMail({ 17 from: config.smtp.username, 18 to, 19 subject, 20 text, 21 html, 22 }); 23}; 24 25module.exports = { 26 sendEmail, 27};