feat: implement comprehensive route-based email routing system

Replace legacy domain-rule based routing with flexible route-based system that supports:
- Multi-criteria matching (recipients, senders, IPs, authentication)
- Four action types (forward, process, deliver, reject)
- Moved DKIM signing to delivery phase for signature validity
- Connection pooling for efficient email forwarding
- Pattern caching for improved performance

This provides more granular control over email routing with priority-based matching and comprehensive test coverage.
This commit is contained in:
2025-05-28 13:23:45 +00:00
parent 88099e120a
commit 2e75961d1c
11 changed files with 717 additions and 168 deletions

View File

@ -323,7 +323,7 @@ export class DataHandler implements IDataHandler {
// Process the email via the UnifiedEmailServer
// Pass the email object, session data, and specify the mode (mta, forward, or process)
// This connects SMTP reception to the overall email system
const processResult = await this.smtpServer.getEmailServer().processEmailByMode(email, session as any, 'mta');
const processResult = await this.smtpServer.getEmailServer().processEmailByMode(email, session as any);
SmtpLogger.info(`Email processed through UnifiedEmailServer: ${email.getMessageId()}`, {
sessionId: session.id,
@ -373,7 +373,7 @@ export class DataHandler implements IDataHandler {
// Process the email via the UnifiedEmailServer in forward mode
try {
const processResult = await this.smtpServer.getEmailServer().processEmailByMode(email, session as any, 'forward');
const processResult = await this.smtpServer.getEmailServer().processEmailByMode(email, session as any);
SmtpLogger.info(`Email forwarded through UnifiedEmailServer: ${email.getMessageId()}`, {
sessionId: session.id,
@ -412,7 +412,7 @@ export class DataHandler implements IDataHandler {
// Process the email via the UnifiedEmailServer in process mode
try {
const processResult = await this.smtpServer.getEmailServer().processEmailByMode(email, session as any, 'process');
const processResult = await this.smtpServer.getEmailServer().processEmailByMode(email, session as any);
SmtpLogger.info(`Email processed directly through UnifiedEmailServer: ${email.getMessageId()}`, {
sessionId: session.id,