This commit is contained in:
Philipp Kunz 2025-05-22 23:09:41 +00:00
parent 6fcc3feb73
commit f058b2d1e7
3 changed files with 50 additions and 2 deletions

View File

@ -1193,7 +1193,6 @@ SmtpLogger.debug(`Parsed email subject: ${subject}`, { subject });
}
}
}, 100); // Short delay before retry
}
}
/**

View File

@ -6,7 +6,10 @@
import * as plugins from '../../../plugins.js';
import type { Email } from '../../core/classes.email.js';
import type { UnifiedEmailServer } from '../../routing/classes.unified.email.server.js';
import type { SmtpState, SmtpCommand } from './constants.js';
// Re-export types from other modules
export { SmtpState } from '../interfaces.js';
export type { SmtpCommand } from './constants.js';
/**
* Interface for components that need cleanup

View File

@ -738,4 +738,50 @@ export class SmtpServer implements ISmtpServer {
this.recoveryState.recovering = false;
}
}
/**
* Clean up all component resources
*/
public async destroy(): Promise<void> {
SmtpLogger.info('Destroying SMTP server components');
// Destroy all components in parallel
const destroyPromises: Promise<void>[] = [];
if (this.sessionManager && typeof this.sessionManager.destroy === 'function') {
destroyPromises.push(Promise.resolve(this.sessionManager.destroy()));
}
if (this.connectionManager && typeof this.connectionManager.destroy === 'function') {
destroyPromises.push(Promise.resolve(this.connectionManager.destroy()));
}
if (this.commandHandler && typeof this.commandHandler.destroy === 'function') {
destroyPromises.push(Promise.resolve(this.commandHandler.destroy()));
}
if (this.dataHandler && typeof this.dataHandler.destroy === 'function') {
destroyPromises.push(Promise.resolve(this.dataHandler.destroy()));
}
if (this.tlsHandler && typeof this.tlsHandler.destroy === 'function') {
destroyPromises.push(Promise.resolve(this.tlsHandler.destroy()));
}
if (this.securityHandler && typeof this.securityHandler.destroy === 'function') {
destroyPromises.push(Promise.resolve(this.securityHandler.destroy()));
}
await Promise.all(destroyPromises);
// Clear recovery state
this.recoveryState = {
recovering: false,
currentRecoveryAttempt: 0,
maxRecoveryAttempts: 3,
lastError: null
};
SmtpLogger.info('All SMTP server components destroyed');
}
}