import { logger } from '../../utils/logger'; export interface MailOptions { to: string; subject: string; html?: string; text?: string; } export interface MailResult { success: boolean; messageId?: string; error?: string; } export class MailService { private static instance: MailService; private constructor() {} static getInstance(): MailService { if (!MailService.instance) { MailService.instance = new MailService(); } return MailService.instance; } async sendMail(options: MailOptions): Promise { logger.info(`[MailService] Sending email to: ${options.to}`); try { const messageId = `msg-${Date.now()}`; logger.info(`[MailService] Email sent successfully: ${messageId}`); return { success: true, messageId }; } catch (error: any) { logger.error(`[MailService] Failed to send email: ${error.message}`); return { success: false, error: error.message }; } } async sendWelcomeEmail(email: string, username: string): Promise { return this.sendMail({ to: email, subject: 'Welcome to Crawlful Hub', html: `

Welcome ${username}!

Thank you for registering.

` }); } async sendPasswordResetEmail(email: string, resetToken: string): Promise { return this.sendMail({ to: email, subject: 'Password Reset', html: `

Click here to reset your password.

` }); } }