This commit is contained in:
2025-05-22 23:02:37 +00:00
parent f065a9c952
commit 50350bd78d
10 changed files with 633 additions and 779 deletions

View File

@ -20,73 +20,12 @@ import { UnifiedEmailServer } from '../../routing/classes.unified.email.server.j
* @returns Configured SMTP server instance
*/
export function createSmtpServer(emailServer: UnifiedEmailServer, options: ISmtpServerOptions): SmtpServer {
// Create session manager
const sessionManager = new SessionManager({
socketTimeout: options.socketTimeout,
connectionTimeout: options.connectionTimeout,
cleanupInterval: options.cleanupInterval
// First create the SMTP server instance
const smtpServer = new SmtpServer({
emailServer,
options
});
// Create security handler
const securityHandler = new SecurityHandler(
emailServer,
undefined, // IP reputation service
options.auth
);
// Create TLS handler
const tlsHandler = new TlsHandler(
sessionManager,
{
key: options.key,
cert: options.cert,
ca: options.ca
}
);
// Create data handler
const dataHandler = new DataHandler(
sessionManager,
emailServer,
{
size: options.size
}
);
// Create command handler
const commandHandler = new CommandHandler(
sessionManager,
{
hostname: options.hostname,
size: options.size,
maxRecipients: options.maxRecipients,
auth: options.auth
},
dataHandler,
tlsHandler,
securityHandler
);
// Create connection manager
const connectionManager = new ConnectionManager(
sessionManager,
(socket, line) => commandHandler.processCommand(socket, line),
{
hostname: options.hostname,
maxConnections: options.maxConnections,
socketTimeout: options.socketTimeout
}
);
// Create and return SMTP server
return new SmtpServer({
emailServer,
options,
sessionManager,
connectionManager,
commandHandler,
dataHandler,
tlsHandler,
securityHandler
});
// Return the configured server
return smtpServer;
}