import FormData from 'form-data'; import Mailgun from 'mailgun.js'; const mailgun = new (Mailgun as any)(FormData); const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY || '', }); const DOMAIN = process.env.MAILGUN_DOMAIN || 'sandbox06aa4efa8cc342878b7470a7c9113df3.mailgun.org'; const FROM = process.env.FROM_EMAIL || `LabWise `; export async function sendEmail({ to, subject, html, }: { to: string; subject: string; html: string; }) { await mg.messages.create(DOMAIN, { from: FROM, to: [to], subject, html, }); } /* ------------------------------------------------------------------ */ /* Shared email layout */ /* ------------------------------------------------------------------ */ function emailLayout(body: string) { return `
LabWise
${body}

© ${new Date().getFullYear()} LabWise — AI-powered lab management

`; } /* ------------------------------------------------------------------ */ /* Email templates */ /* ------------------------------------------------------------------ */ export function verificationEmailHtml(url: string) { return emailLayout(`

Verify your email

Thanks for creating a LabWise account. Click the button below to verify your email address and get started.

Verify Email

Or copy and paste this link into your browser:

${url}

If you didn't create a LabWise account, you can safely ignore this email.

`); } export function resetPasswordEmailHtml(url: string) { return emailLayout(`

Reset your password

We received a request to reset your LabWise password. Click the button below to choose a new one. This link expires in 1 hour.

Reset Password

Or copy and paste this link into your browser:

${url}

If you didn't request a password reset, you can safely ignore this email. Your password won't be changed.

`); }