interface SendEmailParams { to: string subject: string html: string } async function sendEmail({ to, subject, html }: SendEmailParams): Promise { const apiKey = process.env.BREVO_API_KEY if (!apiKey) throw new Error('BREVO_API_KEY not configured') const from = process.env.BREVO_FROM_EMAIL ?? 'noreply@setia.com.my' const res = await fetch('https://api.brevo.com/v3/smtp/email', { method: 'POST', headers: { 'api-key': apiKey, 'Content-Type': 'application/json', }, body: JSON.stringify({ sender: { email: from }, to: [{ email: to }], subject, htmlContent: html, }), }) if (!res.ok) { const text = await res.text() throw new Error(`Brevo API error ${res.status}: ${text}`) } } export async function sendPasswordResetEmail({ to, name, resetLink, }: { to: string name: string resetLink: string }): Promise { await sendEmail({ to, subject: 'IMS — Reset your password', html: `

Hi ${name},

Click the link below to reset your IMS password. The link expires in 1 hour.

${resetLink}

If you did not request a password reset, ignore this email.

`, }) }