Skip to content

Commit

Permalink
Fix get_mx DNS SERVFAIL error crash (#3376)
Browse files Browse the repository at this point in the history
  • Loading branch information
analogic authored Jun 4, 2024
1 parent c4ee966 commit 45d8b3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
- fix(outbound): don't send SNI servername when connecting to an IP
- fix(outbound): chown queue dir after creation #3291
- fix(server): async endpoint.bind() and await in server.js #3366
- fix(outbound): get_mx DNS error handling #3376

### [3.0.3] - 2024-02-07

Expand Down
13 changes: 8 additions & 5 deletions outbound/hmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class HMailItem extends events.EventEmitter {
plugins.run_hooks('get_mx', this, domain);
}

get_mx_respond (retval, mx) {
async get_mx_respond (retval, mx) {
switch (retval) {
case constants.ok: {
this.logdebug(`MX from Plugin: ${this.todo.domain} => 0 ${JSON.stringify(mx)}`);
Expand Down Expand Up @@ -220,18 +220,21 @@ class HMailItem extends events.EventEmitter {
}

// none of the above return codes, drop through to DNS
net_utils.get_mx(this.todo.domain).then(exchanges => {
try {
const exchanges = await net_utils.get_mx(this.todo.domain);

if (exchanges.length) {
this.found_mx(this.sort_mx(exchanges))
}
else {
for (const rcpt of this.todo.rcpt_to) {
this.extend_rcpt_with_dsn(rcpt, DSN.addr_bad_dest_system(`Nowhere to deliver mail to for domain: ${this.todo.domain}`));
this.extend_rcpt_with_dsn(rcpt, DSN.addr_bad_dest_system(`Nowhere to deliver mail to for domain: ${this.todo.domain}`))
}
this.bounce(`Nowhere to deliver mail to for domain: ${this.todo.domain}`);
}
})
.catch(this.get_mx_err)
} catch (e) {
this.get_mx_error(e);
}
}

get_mx_error (err) {
Expand Down

0 comments on commit 45d8b3d

Please sign in to comment.