21 lines
461 B
JavaScript
21 lines
461 B
JavaScript
const nodemailer = require("nodemailer");
|
|
|
|
exports.sendEmail = async (to, subject, body) => {
|
|
const transporter = nodemailer.createTransport({
|
|
host: process.env.MAIL_HOST,
|
|
port: process.env.MAIL_PORT,
|
|
secure: false,
|
|
auth: {
|
|
user: process.env.MAIL_USER,
|
|
pass: process.env.MAIL_PASS,
|
|
},
|
|
});
|
|
|
|
await transporter.sendMail({
|
|
from: process.env.MAIL_FROM || "noreply@example.com",
|
|
to,
|
|
subject,
|
|
html: body,
|
|
});
|
|
};
|