mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
ready to test
Testing Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -24,44 +24,6 @@ const transporter = nodemailer.createTransport({
|
||||
},
|
||||
});
|
||||
|
||||
const buildEmailTemplate = ({ title, body }) => {
|
||||
return `
|
||||
<div style="font-family:Arial,sans-serif;max-width:520px;margin:auto;border:1px solid #e5e7eb;border-radius:10px;overflow:hidden">
|
||||
|
||||
<!-- LOGO -->
|
||||
<div style="padding:20px;text-align:center;background:#232f3e">
|
||||
<img src="${process.env.APP_LOGO_URL}" alt="Philproperties" style="height:42px" />
|
||||
</div>
|
||||
|
||||
<!-- CONTENT -->
|
||||
<div style="padding:26px">
|
||||
<h2 style="color:#111827;margin-bottom:14px">${title}</h2>
|
||||
${body}
|
||||
|
||||
<!-- FORMAL CLOSING -->
|
||||
<div style="margin-top:24px">
|
||||
<p style="margin:0">Regards,</p>
|
||||
<p style="margin:4px 0 0;font-weight:600;color:#111827">
|
||||
Philproperties IT Team
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- FOOTER -->
|
||||
<div style="padding:14px;text-align:center;font-size:12px;color:#6b7280;border-top:1px solid #e5e7eb">
|
||||
This is an automated message from STARR System. Please do not reply.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a 6-digit OTP to the given email address.
|
||||
* @param {string} to - recipient email
|
||||
* @param {string} otp - 6-digit code
|
||||
* @param {number} expiryMinutes
|
||||
*/
|
||||
const sendEmail = async ({ to, type, data = {} }) => {
|
||||
try {
|
||||
const templateFn = emailTemplates[type];
|
||||
@@ -70,9 +32,7 @@ const sendEmail = async ({ to, type, data = {} }) => {
|
||||
throw new Error(`Email template "${type}" not found`);
|
||||
}
|
||||
|
||||
const { subject, title, body } = templateFn(data);
|
||||
|
||||
const html = buildEmailTemplate({ title, body });
|
||||
const { subject, text } = templateFn(data);
|
||||
|
||||
return await new Promise((resolve, reject) => {
|
||||
transporter.sendMail(
|
||||
@@ -83,7 +43,7 @@ const sendEmail = async ({ to, type, data = {} }) => {
|
||||
},
|
||||
to,
|
||||
subject,
|
||||
html,
|
||||
text,
|
||||
},
|
||||
(err, info) => {
|
||||
if (err) return reject(err);
|
||||
@@ -96,4 +56,6 @@ const sendEmail = async ({ to, type, data = {} }) => {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = sendEmail;
|
||||
const ping = () => transporter.verify();
|
||||
|
||||
module.exports = { sendEmail, ping };
|
||||
Reference in New Issue
Block a user