43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { brevoService } from "@/common/email/brevoApi";
|
|
import ApiError from "@/common/utils/helper/ApiError";
|
|
|
|
export async function sendOtpEmailForMinglarAdmin(
|
|
emailAddress: string,
|
|
otp: string | number
|
|
): Promise<{
|
|
sent: boolean;
|
|
// messageId: string
|
|
}> {
|
|
|
|
const subject = "Your Minglar Verification Code";
|
|
|
|
const htmlContent = `
|
|
<p>Hi there,</p>
|
|
<p>To continue your Minglar Admin registration, please use the following One-Time Password (OTP):</p>
|
|
<p><strong>${otp}</strong></p>
|
|
<p>This code is valid for 5 minutes.</p>
|
|
<p>For your security, please do not share this code with anyone.</p>
|
|
<p>If you did not request this OTP, please ignore this email.</p>
|
|
<p>Warm regards,<br/>Minglar Team</p>
|
|
`;
|
|
|
|
try {
|
|
const result = await brevoService.sendEmail({
|
|
recipients: [{ email: emailAddress }],
|
|
subject,
|
|
htmlContent,
|
|
});
|
|
|
|
console.log("📧 Email sent successfully:", result);
|
|
|
|
return {
|
|
sent: true,
|
|
// messageId: result.messageId
|
|
};
|
|
} catch (err) {
|
|
console.error("Brevo email send failed:", err);
|
|
throw new ApiError(500, "Failed to send OTP to minglar admin via email.");
|
|
}
|
|
}
|
|
|