From 08147c8c206ed5f3d16ce6d6ade0fa3e0c6df98e Mon Sep 17 00:00:00 2001 From: NickOvt Date: Mon, 21 Oct 2024 10:56:54 +0300 Subject: [PATCH] fix(zilter-tempfail): in case of Zilter tempfail show error (#26) --- index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e7a6a17..ff4d3f8 100644 --- a/index.js +++ b/index.js @@ -169,6 +169,7 @@ module.exports.init = async app => { const messageSize = envelope.headers.build().length + envelope.bodySize; // RFC822 size (size of Headers + Body) let passEmail = true; + let isTempFail = false; const messageHeadersList = []; @@ -237,6 +238,10 @@ module.exports.init = async app => { } if (resBodyJson.action && resBodyJson.action !== 'accept') { + if (resBodyJson.action === 'tempfail') { + isTempFail = true; + } + // not accepted passEmail = false; loggelfForEveryUser(app, subject, { @@ -292,7 +297,10 @@ module.exports.init = async app => { if (!passEmail) { // rejected - throw app.reject(envelope, 'banned', messageinfo, '550 SMTP ACCESS DENIED - ABUSE PREVENTION HAS TRIGGERED A BAN DUE TO REACHED RATE LIMITS.'); + if (isTempFail) { + throw app.reject(envelope, 'tempfail', messageinfo, 'Temporary error, please try again later.'); + } + throw app.reject(envelope, 'banned', messageinfo, '550 SMTP ACCESS DENIED - ABUSE PREVENTION HAS TRIGGERED A BAN.'); } return;