send mail even in case of parsing error ...

This commit is contained in:
Andreas Knuth 2026-03-07 17:04:50 -06:00
parent 757855866c
commit cd44449067
1 changed files with 5 additions and 5 deletions

View File

@ -135,6 +135,7 @@ export class MessageProcessor {
let finalRawBytes = rawBytes;
let fromAddrFinal = fromAddr;
let isBounce = false;
let parsedFinal: ParsedMail | null = null; // <-- Hier deklarieren
try {
const parsed = await parseEmail(rawBytes);
@ -147,7 +148,6 @@ export class MessageProcessor {
subject,
workerName,
);
isBounce = bounceResult.isBounce;
finalRawBytes = bounceResult.rawBytes;
@ -165,17 +165,17 @@ export class MessageProcessor {
}
// Re-parse after modifications for rules processing
var parsedFinal = await parseEmail(finalRawBytes);
parsedFinal = await parseEmail(finalRawBytes);
} catch (err: any) {
log(
`⚠ Parsing/Logic Error: ${err.message ?? err}. Sending original.`,
`⚠ Parsing/Logic Error: ${err.message ?? err}. Sending original RAW mail without rules.`,
'WARNING',
workerName,
);
log(`Full error: ${err.stack ?? err}`, 'ERROR', workerName);
fromAddrFinal = fromAddr;
isBounce = false;
var parsedFinal = await parseEmail(rawBytes);
parsedFinal = null; // <-- GANZ WICHTIG: Kein erneuter Parse-Versuch!
}
// 6. BLOCKLIST CHECK
@ -215,7 +215,7 @@ export class MessageProcessor {
}
// Process rules (OOO, Forwarding) — not for bounces or already forwarded
if (!isBounce && !skipRules) {
if (!isBounce && !skipRules && parsedFinal !== null) {
const metricsCallback = (action: 'autoreply' | 'forward', dom: string) => {
if (action === 'autoreply') this.metrics?.incrementAutoreply(dom);
else if (action === 'forward') this.metrics?.incrementForward(dom);