integrated sending mail from brevo

This commit is contained in:
2025-11-14 19:06:47 +05:30
parent 54c024fc4f
commit 4ee0819051
6 changed files with 44 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ export const handler = safeHandler(async (
): Promise<APIGatewayProxyResult> => {
// Parse request body
let body: { email?: string };
try {
body = event.body ? JSON.parse(event.body) : {};
} catch (error) {

View File

@@ -4,7 +4,10 @@ import ApiError from "@/common/utils/helper/ApiError";
export async function sendOtpEmailForHost(
emailAddress: string,
otp: string | number
): Promise<void> {
): Promise<{
sent: boolean;
// messageId: string
}> {
const subject = "OTP for Host Registration";
@@ -16,11 +19,18 @@ export async function sendOtpEmailForHost(
`;
try {
await brevoService.sendEmail({
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.");