Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZMS-56 #363

Merged
merged 4 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed breaking tests
andris9 committed Jan 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a9d790acbf693753965714943af4d19a1d2f193f
17 changes: 10 additions & 7 deletions lib/bounces.js
Original file line number Diff line number Diff line change
@@ -106,10 +106,13 @@ module.exports.check = (input, category) => {
};
};

module.exports.canSendBounce = delivery => {
module.exports.canSendBounce = (delivery, options) => {
options = options || {};
let logName = options.logName || 'Bounce';

if (delivery.skipBounce) {
log.info(
this.logName,
logName,
'id=%s %s.%s SKIPBOUNCE Skip bounce to %s as defined by routing',
delivery.sessionId,
delivery.id,
@@ -121,7 +124,7 @@ module.exports.canSendBounce = delivery => {

if (/^mailer-daemon@/i.test(delivery.from) || !delivery.from) {
log.info(
this.logName,
logName,
'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to envelope (MAIL FROM=%s)',
delivery.sessionId,
delivery.id,
@@ -137,7 +140,7 @@ module.exports.canSendBounce = delivery => {
let xAutoResponseSuppress = delivery.headers.getFirst('X-Auto-Response-Suppress');
if (/\ball\b/i.test(xAutoResponseSuppress)) {
log.info(
this.logName,
logName,
'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to header (%s=%s)',
delivery.sessionId,
delivery.id,
@@ -152,7 +155,7 @@ module.exports.canSendBounce = delivery => {
let autoSubmitted = delivery.headers.getFirst('Auto-Submitted');
if (/\bauto-(generated|replied)\b/i.test(autoSubmitted)) {
log.info(
this.logName,
logName,
'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to header (%s=%s)',
delivery.sessionId,
delivery.id,
@@ -167,7 +170,7 @@ module.exports.canSendBounce = delivery => {
let contentType = delivery.headers.getFirst('Content-Type');
if (/^multipart\/report\b/i.test(contentType)) {
log.info(
this.logName,
logName,
'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to header (%s=%s)',
delivery.sessionId,
delivery.id,
@@ -181,7 +184,7 @@ module.exports.canSendBounce = delivery => {

if (delivery.parsedEnvelope && /^mailer-daemon@/i.test(delivery.parsedEnvelope.from)) {
log.info(
this.logName,
logName,
'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to header (%s=%s)',
delivery.sessionId,
delivery.id,
2 changes: 1 addition & 1 deletion lib/mail-queue.js
Original file line number Diff line number Diff line change
@@ -837,7 +837,7 @@ class MailQueue {
to: deliveryEntry.recipient
};

if (!bounces.canSendBounce(deliveryEntry)) {
if (!bounces.canSendBounce(deliveryEntry, { logName: 'Queue' })) {
return false;
}

2 changes: 1 addition & 1 deletion lib/sender.js
Original file line number Diff line number Diff line change
@@ -1416,7 +1416,7 @@ class Sender extends EventEmitter {
}

sendBounceMessage(delivery, bounce, smtpResponse) {
if (!bounces.canSendBounce(delivery)) {
if (!bounces.canSendBounce(delivery, { logName: this.logName })) {
return false;
}