45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { brevoService } from "@/common/email/brevoApi";
|
|
import ApiError from "@/common/utils/helper/ApiError";
|
|
|
|
export async function resendOtpEmail(
|
|
emailAddress: string,
|
|
otp: string | number,
|
|
role: string
|
|
): Promise<{
|
|
sent: boolean;
|
|
// messageId: string
|
|
}> {
|
|
|
|
const subject = "Your Minglar Verification Code";
|
|
|
|
const htmlContent = `
|
|
<p>Hi ${role},</p>
|
|
<p>Here's your verification code to get started:</p>
|
|
<p><strong>${otp}</strong></p>
|
|
<p>This code is valid for the next 5 minutes.</p>
|
|
<p>Once verified, you can continue setting up your Minglar account. If you didn't request this, you can safely ignore this email.</p>
|
|
<p>Need help? Reach out to us at info@minglargroup.com.</p>
|
|
<p>Warm regards,<br/>Team Minglar</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 host via email.");
|
|
}
|
|
}
|
|
|
|
|