From 6ca9d009966b860c201e8b0c7c24856263369c3e Mon Sep 17 00:00:00 2001 From: NickOvt Date: Mon, 23 Dec 2024 10:55:22 +0200 Subject: [PATCH] fix(catchall-header): ZMS-184 (#49) * in case of catchall address, add custom header to read the original recipient * make header configurable * fix typo --- config/wildduck.yaml | 2 ++ index.js | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/config/wildduck.yaml b/config/wildduck.yaml index 04b51d7..1e148cf 100644 --- a/config/wildduck.yaml +++ b/config/wildduck.yaml @@ -100,3 +100,5 @@ auth: # If a public key has fewer bits than required, then DKIM and ARC keys are considered failing by policy minBitLength: 1024 + +originalRcptHeader: 'X-Zone-Original-Rcpt' diff --git a/index.js b/index.js index b66c073..c0c7c59 100644 --- a/index.js +++ b/index.js @@ -790,6 +790,12 @@ exports.real_rcpt_handler = function (next, connection, params) { return hookDone(err); } + if (addressData.address.includes('*')) { + // wildcard/catchall address received email + const originalRcptHeaderName = plugin.cfg?.originalRcptHeader || 'X-Original-Rcpt'; + txn.add_header(originalRcptHeaderName, address); + } + if (addressData && addressData.targets) { return plugin .handle_forwarding_address(connection, address, addressData)