This commit is contained in:
2025-05-07 14:33:20 +00:00
parent 5ad43470f3
commit 2ee66ef967
14 changed files with 578 additions and 547 deletions

View File

@ -168,6 +168,9 @@ export class MtaService {
/** Whether the service is currently running */
private running = false;
/** SMTP rule engine for incoming emails */
public smtpRuleEngine: plugins.smartrule.SmartRule<Email>;
/**
* Initialize the MTA service
@ -188,6 +191,8 @@ export class MtaService {
this.dkimVerifier = new DKIMVerifier(this);
this.dnsManager = new DNSManager(this);
this.apiManager = new ApiManager();
// Initialize SMTP rule engine
this.smtpRuleEngine = new plugins.smartrule.SmartRule<Email>();
// Initialize stats
this.stats = {
@ -408,6 +413,12 @@ export class MtaService {
throw new Error('MTA service is not running');
}
// Apply SMTP rule engine decisions
try {
await this.smtpRuleEngine.makeDecision(email);
} catch (err) {
console.error('Error executing SMTP rules:', err);
}
try {
console.log(`Processing incoming email from ${email.from} to ${email.to}`);

View File

@ -301,7 +301,7 @@ export class SMTPServer {
this.sessions.delete(socket);
}
private processEmailData(socket: plugins.net.Socket | plugins.tls.TLSSocket, data: string): void {
private async processEmailData(socket: plugins.net.Socket | plugins.tls.TLSSocket, data: string): Promise<void> {
const session = this.sessions.get(socket);
if (!session) return;
@ -384,8 +384,12 @@ export class SMTPServer {
mightBeSpam: email.mightBeSpam
});
// Process or forward the email as needed
// this.mtaRef.processIncomingEmail(email); // You could add this method to your MTA service
// Process or forward the email via MTA service
try {
await this.mtaRef.processIncomingEmail(email);
} catch (err) {
console.error('Error in MTA processing of incoming email:', err);
}
} catch (error) {
console.error('Error parsing email:', error);
}