Skip to content

Commit

Permalink
fix(zilter-tempfail): in case of Zilter tempfail show error (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickOvt authored Oct 21, 2024
1 parent 08775a5 commit 08147c8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 08147c8

Please sign in to comment.