import { transporter } from "@/lib/nodemailer"; const escapeHtml = (value: string) => value .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); export const sendPasswordResetEmail = async ( { email, name, resetUrl }: { email: string; name?: string | null; resetUrl: string } ) => { try { if (!process.env.NODEMAILER_EMAIL || !process.env.NODEMAILER_PASSWORD) { throw new Error('Email credentials not configured'); } const firstName = name?.trim().split(' ')[0] || 'there'; const escapedFirstName = escapeHtml(firstName); const escapedResetUrl = escapeHtml(encodeURI(resetUrl)); const html = `
Hi ${escapedFirstName},
We received a request to reset your Openstock password. Use the button below to choose a new one.
Reset passwordIf you did not request this, you can safely ignore this email.