otp : gwm

This commit is contained in:
Gowtham M 2025-12-08 17:58:54 +05:30
parent dffdc00142
commit 3972907947

View File

@ -1,18 +1,24 @@
const nodemailer = require("nodemailer");
exports.sendEmail = async (to, subject, body) => {
const port = Number(process.env.MAIL_PORT);
const transporter = nodemailer.createTransport({
host: process.env.MAIL_HOST,
port: process.env.MAIL_PORT,
secure: false,
host: process.env.MAIL_HOST,
port,
secure: port === 465, // SSL
requireTLS: port === 587, // Enforce TLS for 587
auth: {
user: process.env.MAIL_USER,
pass: process.env.MAIL_PASS,
},
});
await transporter.sendMail({
from: process.env.MAIL_FROM || "noreply@example.com",
from: process.env.SMTP_FROM || process.env.SMTP_USER,
to,
subject,
html: body,