import nodemailer from "nodemailer"; import { createLogger } from "@/lib/logger"; const log = createLogger("email"); const transporter = nodemailer.createTransport({ host: process.env.SMTP_HOST, port: Number(process.env.SMTP_PORT) || 587, secure: process.env.SMTP_SECURE === "true", auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS, }, }); interface SendEmailOptions { to: string; subject: string; html: string; text?: string; } export async function sendEmail({ to, subject, html, text }: SendEmailOptions) { try { const info = await transporter.sendMail({ from: process.env.SMTP_FROM || process.env.SMTP_USER, to, subject, html, text, }); log.info("Email sent", { to, subject, messageId: info.messageId }); return { success: true, messageId: info.messageId }; } catch (error) { log.error("Failed to send email", { to, subject, error }); return { success: false, error }; } } export function generateVerificationEmailHtml(url: string, userName: string) { return `
`; } export function generateResetPasswordEmailHtml(url: string, userName: string) { return ` `; }