integrated sending mail from brevo
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user