import nodemailer from 'nodemailer' const transporter = nodemailer.createTransport({ host: process.env.SMTP_HOST, port: Number(process.env.SMTP_PORT) || 587, secure: false, auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS, }, }) interface SendBriefEmailOptions { to: string name: string company: string brief: string } export async function sendBriefToClient({ to, name, brief }: SendBriefEmailOptions) { const firstName = name.split(' ')[0] || 'there' // Convert markdown-style **bold** to HTML const htmlBrief = brief .replace(/\*\*(.*?)\*\*/g, '$1') .replace(/---/g, '
') .replace(/\n\n/g, '

') .replace(/\n/g, '
') await transporter.sendMail({ from: `"LetsBe." <${process.env.SMTP_FROM || 'hello@letsbe.biz'}>`, to, subject: 'Your Project Brief from LetsBe.', html: `

LetsBe.

Hi ${firstName},

Thank you for configuring your project with us. Here's your personalized brief:

${htmlBrief}

Book a Consultation

Or reply to this email — we'll get back to you within 24 hours.

LetsBe Solutions LLC
`, }) } export async function sendLeadNotification({ to, name, company, brief }: SendBriefEmailOptions & { services: string[]; email: string }) { const adminEmail = process.env.ADMIN_EMAIL || 'hello@letsbe.biz' await transporter.sendMail({ from: `"LetsBe. Configurator" <${process.env.SMTP_FROM || 'hello@letsbe.biz'}>`, to: adminEmail, subject: `New Lead: ${name}${company ? ` — ${company}` : ''}`, html: `

New Configurator Submission

Name:${name}
Company:${company || '—'}
Email:${to}
${brief}
`, }) }