interface ActivationData { portName: string; link: string; ttlHours: number; recipientName?: string; } interface ResetData { portName: string; link: string; ttlMinutes: number; recipientName?: string; } const LOGO_URL = 'https://s3.portnimara.com/images/Port%20Nimara%20New%20Logo-Circular%20Frame_250px.png'; const BACKGROUND_URL = 'https://s3.portnimara.com/images/Overhead_1_blur.png'; function shell(opts: { title: string; body: string }): string { return ` ${opts.title}
Port Nimara Logo
${opts.body}
`; } export function activationEmail(data: ActivationData): { subject: string; html: string; text: string; } { const subject = `Activate your ${data.portName} client portal account`; const greeting = data.recipientName ? `Dear ${escapeHtml(data.recipientName)},` : 'Welcome,'; const body = `

Welcome to ${escapeHtml(data.portName)}

${greeting}

You've been invited to access the ${escapeHtml(data.portName)} client portal. Click the button below to set your password and activate your account. The link expires in ${data.ttlHours} hours.

Activate account

If the button doesn't work, paste this link into your browser:
${data.link}

Thank you,
${escapeHtml(data.portName)} CRM

`; const text = [ `Welcome to ${data.portName}`, '', `You've been invited to access the ${data.portName} client portal.`, `Activate your account by visiting: ${data.link}`, '', `The link expires in ${data.ttlHours} hours.`, '', `Thank you,`, `${data.portName} CRM`, ].join('\n'); return { subject, html: shell({ title: subject, body }), text }; } export function resetEmail(data: ResetData): { subject: string; html: string; text: string } { const subject = `Reset your ${data.portName} client portal password`; const greeting = data.recipientName ? `Dear ${escapeHtml(data.recipientName)},` : 'Hello,'; const body = `

Password reset

${greeting}

We received a request to reset the password on your ${escapeHtml(data.portName)} client portal account. Click the button below to choose a new one. The link expires in ${data.ttlMinutes} minutes.

Reset password

If you didn't request this, you can safely ignore this email — your password will remain unchanged.

Thank you,
${escapeHtml(data.portName)} CRM

`; const text = [ `Password reset for ${data.portName}`, '', `Reset your password by visiting: ${data.link}`, `The link expires in ${data.ttlMinutes} minutes.`, '', `If you didn't request this, you can safely ignore this email.`, '', `Thank you,`, `${data.portName} CRM`, ].join('\n'); return { subject, html: shell({ title: subject, body }), text }; } function escapeHtml(str: string): string { return str .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); }