import type { IBaseConfig, ITlsConfig, IQueueConfig, IRateLimitConfig, IMonitoringConfig } from './base.config.js'; /** * Email processing modes */ export type EmailProcessingMode = 'forward' | 'mta' | 'process'; /** * Domain rule for email routing */ export interface IDomainRule { /** * Pattern to match (e.g., "*@example.com") */ pattern: string; /** * Processing mode */ mode: EmailProcessingMode; /** * Target server for forwarding mode */ target?: { /** * Target server hostname or IP */ server: string; /** * Target server port */ port?: number; /** * Whether to use TLS for forwarding */ useTls?: boolean; }; /** * MTA options for mta mode */ mtaOptions?: { /** * Domain for MTA */ domain?: string; /** * Whether to sign with DKIM */ dkimSign?: boolean; /** * DKIM options */ dkimOptions?: { /** * Domain name for DKIM */ domainName: string; /** * Key selector */ keySelector: string; /** * Private key */ privateKey?: string; }; }; /** * Whether to scan content in process mode */ contentScanning?: boolean; /** * Content scanners to apply */ scanners?: Array<{ /** * Scanner type */ type: 'spam' | 'virus' | 'attachment'; /** * Threshold for scanner */ threshold?: number; /** * Action to take */ action: 'tag' | 'reject'; /** * Blocked file extensions for attachment scanner */ blockedExtensions?: string[]; }>; /** * Email transformations to apply */ transformations?: Array<{ /** * Transformation type */ type: 'addHeader'; /** * Header name */ header?: string; /** * Header value */ value?: string; }>; } /** * Email service configuration */ export interface IEmailConfig extends IBaseConfig { /** * Whether to enable email functionality */ useEmail?: boolean; /** * Whether to use MTA service (legacy compatibility) */ useMta?: boolean; /** * MTA configuration (legacy compatibility) */ mtaConfig?: IMtaConfig; /** * Whether the email server is behind SmartProxy (uses internal ports) */ behindSmartProxy?: boolean; /** * Email server configuration for both sending and receiving */ serverConfig?: IEmailServerConfig; /** * Email ports to listen on */ ports?: number[]; /** * Email server hostname */ hostname?: string; /** * TLS configuration */ tls?: ITlsConfig; /** * Domain routing rules */ domainRules?: IDomainRule[]; /** * Default processing mode for emails */ defaultMode?: EmailProcessingMode; /** * Default server for forwarding */ defaultServer?: string; /** * Default port for forwarding */ defaultPort?: number; /** * Default TLS setting for forwarding */ defaultTls?: boolean; /** * Maximum message size in bytes */ maxMessageSize?: number; /** * Authentication settings */ auth?: { /** * Whether authentication is required */ required?: boolean; /** * Supported authentication methods */ methods?: ('PLAIN' | 'LOGIN' | 'OAUTH2')[]; /** * User credentials */ users?: Array<{username: string, password: string}>; }; /** * Queue configuration */ queue?: IQueueConfig; /** * Template configuration */ templateConfig?: { /** * Default sender email address */ from?: string; /** * Default reply-to email address */ replyTo?: string; /** * Default footer HTML */ footerHtml?: string; /** * Default footer text */ footerText?: string; }; /** * Whether to load templates from directory */ loadTemplatesFromDir?: boolean; /** * Directory path for email templates */ templatesDir?: string; } /** * MTA configuration */ export interface IMtaConfig { /** * SMTP server configuration */ smtp?: { /** * Whether to enable the SMTP server */ enabled?: boolean; /** * Port to listen on */ port?: number; /** * SMTP server hostname */ hostname?: string; /** * Maximum allowed email size in bytes */ maxSize?: number; }; /** * TLS configuration */ tls?: ITlsConfig; /** * Outbound email configuration */ outbound?: { /** * Maximum concurrent sending jobs */ concurrency?: number; /** * Retry configuration */ retries?: { /** * Maximum number of retries per message */ max?: number; /** * Initial delay between retries (milliseconds) */ delay?: number; /** * Whether to use exponential backoff for retries */ useBackoff?: boolean; }; /** * Rate limiting configuration */ rateLimit?: IRateLimitConfig; /** * IP warmup configuration */ warmup?: { /** * Whether IP warmup is enabled */ enabled?: boolean; /** * IP addresses to warm up */ ipAddresses?: string[]; /** * Target domains to warm up */ targetDomains?: string[]; /** * Allocation policy to use */ allocationPolicy?: string; /** * Fallback percentage for ESP routing during warmup */ fallbackPercentage?: number; }; /** * Reputation monitoring configuration */ reputation?: IMonitoringConfig & { /** * Alert thresholds */ alertThresholds?: { /** * Minimum acceptable reputation score */ minReputationScore?: number; /** * Maximum acceptable complaint rate */ maxComplaintRate?: number; }; }; }; /** * Security settings */ security?: { /** * Whether to use DKIM signing */ useDkim?: boolean; /** * Whether to verify inbound DKIM signatures */ verifyDkim?: boolean; /** * Whether to verify SPF on inbound */ verifySpf?: boolean; /** * Whether to verify DMARC on inbound */ verifyDmarc?: boolean; /** * Whether to enforce DMARC policy */ enforceDmarc?: boolean; /** * Whether to use TLS for outbound when available */ useTls?: boolean; /** * Whether to require valid certificates */ requireValidCerts?: boolean; /** * Log level for email security events */ securityLogLevel?: 'info' | 'warn' | 'error'; /** * Whether to check IP reputation for inbound emails */ checkIPReputation?: boolean; /** * Whether to scan content for malicious payloads */ scanContent?: boolean; /** * Action to take when malicious content is detected */ maliciousContentAction?: 'tag' | 'quarantine' | 'reject'; /** * Minimum threat score to trigger action */ threatScoreThreshold?: number; /** * Whether to reject connections from high-risk IPs */ rejectHighRiskIPs?: boolean; }; /** * Domains configuration */ domains?: { /** * List of domains that this MTA will handle as local */ local?: string[]; /** * Whether to auto-create DNS records */ autoCreateDnsRecords?: boolean; /** * DKIM selector to use */ dkimSelector?: string; }; /** * Queue configuration */ queue?: IQueueConfig; } /** * Email server configuration */ export interface IEmailServerConfig { /** * Server ports */ ports?: number[]; /** * Server hostname */ hostname?: string; /** * TLS configuration */ tls?: ITlsConfig; /** * Security settings */ security?: { /** * Whether to use DKIM signing */ useDkim?: boolean; /** * Whether to verify inbound DKIM signatures */ verifyDkim?: boolean; /** * Whether to verify SPF on inbound */ verifySpf?: boolean; /** * Whether to verify DMARC on inbound */ verifyDmarc?: boolean; /** * Whether to enforce DMARC policy */ enforceDmarc?: boolean; /** * Whether to use TLS for outbound when available */ useTls?: boolean; /** * Whether to require valid certificates */ requireValidCerts?: boolean; /** * Log level for email security events */ securityLogLevel?: 'info' | 'warn' | 'error'; /** * Whether to check IP reputation for inbound emails */ checkIPReputation?: boolean; /** * Whether to scan content for malicious payloads */ scanContent?: boolean; /** * Action to take when malicious content is detected */ maliciousContentAction?: 'tag' | 'quarantine' | 'reject'; /** * Minimum threat score to trigger action */ threatScoreThreshold?: number; }; /** * Delivery settings */ delivery?: { /** * Concurrency settings */ concurrency?: number; /** * Rate limiting configuration */ rateLimit?: IRateLimitConfig; /** * Retry configuration */ retries?: { /** * Maximum retry attempts */ max?: number; /** * Base delay between retries in milliseconds */ delay?: number; /** * Whether to use exponential backoff */ useBackoff?: boolean; }; }; }