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: `
Hi ${firstName},
Thank you for configuring your project with us. Here's your personalized brief:
${htmlBrief}
Or reply to this email — we'll get back to you within 24 hours.