export interface EmailConfig { provider: EmailProvider; apiKey?: string; from: string; replyTo?: string; onSent?: (result: EmailResult) => Promise; onError?: (error: EmailError) => void; footer?: EmailFooterConfig; } export type EmailProvider = 'resend' | 'sendgrid' | 'ses' | 'postmark' | 'smtp'; export interface SendEmailOptions> { to: string | string[]; template: string | EmailTemplate; data?: T; from?: string; replyTo?: string; cc?: string | string[]; bcc?: string | string[]; attachments?: Attachment[]; schedule?: Date; priority?: 'high' | 'normal' | 'low'; tags?: string[]; metadata?: Record; } export interface Attachment { filename: string; content: string | Buffer; contentType?: string; encoding?: string; } export interface EmailResult { id: string; provider: EmailProvider; to: string[]; template?: string; sentAt: Date; status: 'sent' | 'queued' | 'scheduled' | 'failed'; error?: string; } export interface EmailError { code: string; message: string; provider: EmailProvider; originalError?: any; } export interface BatchEmailOptions> { template: string | EmailTemplate; recipients: Array<{ to: string; data?: T; metadata?: Record; }>; from?: string; replyTo?: string; schedule?: Date; } export interface BatchEmailResult { batchId: string; total: number; successful: number; failed: number; results: EmailResult[]; } export interface EmailTemplate> { id: string; name: string; subject: string | ((data: T) => string); preview?: string | ((data: T) => string); body: { html: string | ((data: T) => string); text?: string | ((data: T) => string); }; metadata?: { category?: string; tags?: string[]; version?: number; }; includeFooter?: boolean; // Allow templates to opt out of footer } export interface EmailFooterConfig { html?: string | (() => string); text?: string | (() => string); unsubscribe?: { enabled: boolean; url?: string; text?: string; }; privacy?: { enabled: boolean; url?: string; text?: string; }; disclaimer?: { enabled: boolean; text: string; }; company?: { name: string; address?: string; website?: string; }; }