Skip to content

Commit

Permalink
ZMS-185 (#33)
Browse files Browse the repository at this point in the history
* fix logical error with tempfail

* fix subject issue when using api. add debugJson to gelf

* safer delete with check

* Add better SMTP error message

* make message shorter
  • Loading branch information
NickOvt authored Nov 7, 2024
1 parent a223d48 commit 9ebac66
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ module.exports.init = async app => {
subject = subject.substring(0, subjectMaxLength);
const messageIdHeaderVal = allHeadersParsed['Message-ID']?.replace('<', '').replace('>', '');

let zilterResponse;

// Call Zilter with required params
try {
const res = await undici.request(zilterUrl, {
Expand All @@ -220,6 +222,8 @@ module.exports.init = async app => {

const debugJson = { ...resBodyJson };

zilterResponse = resBodyJson;

['SENDER', 'SENDER_GROUP', 'WEBHOOK'].forEach(sym => {
if (debugJson.symbols) {
delete debugJson.symbols[sym];
Expand Down Expand Up @@ -312,7 +316,12 @@ module.exports.init = async app => {

if (!passEmail) {
// rejected
throw app.reject(envelope, 'banned', messageinfo, '550 SMTP ACCESS DENIED - ABUSE PREVENTION HAS TRIGGERED A BAN.');
throw app.reject(
envelope,
'banned',
messageinfo,
`550 ${zilterResponse && zilterResponse.symbols ? `SENDING BLOCKED, REASON: ${zilterResponse.symbols.REJECT_REASON}` : 'SENDING BLOCKED'}`
);
}

if (isTempFail) {
Expand Down

0 comments on commit 9ebac66

Please sign in to comment.