otp : gwm
This commit is contained in:
parent
dffdc00142
commit
3972907947
@ -1,18 +1,24 @@
|
|||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
|
|
||||||
exports.sendEmail = async (to, subject, body) => {
|
exports.sendEmail = async (to, subject, body) => {
|
||||||
|
|
||||||
|
const port = Number(process.env.MAIL_PORT);
|
||||||
|
|
||||||
const transporter = nodemailer.createTransport({
|
const transporter = nodemailer.createTransport({
|
||||||
host: process.env.MAIL_HOST,
|
|
||||||
port: process.env.MAIL_PORT,
|
host: process.env.MAIL_HOST,
|
||||||
secure: false,
|
port,
|
||||||
|
secure: port === 465, // SSL
|
||||||
|
requireTLS: port === 587, // Enforce TLS for 587
|
||||||
auth: {
|
auth: {
|
||||||
user: process.env.MAIL_USER,
|
user: process.env.MAIL_USER,
|
||||||
pass: process.env.MAIL_PASS,
|
pass: process.env.MAIL_PASS,
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await transporter.sendMail({
|
await transporter.sendMail({
|
||||||
from: process.env.MAIL_FROM || "noreply@example.com",
|
from: process.env.SMTP_FROM || process.env.SMTP_USER,
|
||||||
to,
|
to,
|
||||||
subject,
|
subject,
|
||||||
html: body,
|
html: body,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user