40 lines
1001 B
TypeScript
40 lines
1001 B
TypeScript
import { brevoService } from "@/common/email/brevoApi";
|
||
import ApiError from "@/common/utils/helper/ApiError";
|
||
|
||
export async function sendOtpEmailForHost(
|
||
emailAddress: string,
|
||
otp: string | number
|
||
): Promise<{
|
||
sent: boolean;
|
||
// messageId: string
|
||
}> {
|
||
|
||
const subject = "OTP for Host Registration";
|
||
|
||
const htmlContent = `
|
||
<p>Dear Host,</p>
|
||
<p>You’re almost all set! 🎉</p>
|
||
<p>Enter <strong>${otp}</strong> to wrap your registration.</p>
|
||
<p>This code will be valid for the next 5 minutes.</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 host via email.");
|
||
}
|
||
}
|