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 = "New OTP from Minglar Team"; const htmlContent = `

Dear ${role},

Your new OTP is: ${otp}

This code will be valid for the next 5 minutes.

Warm regards,
Minglar Team

`; 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."); } }