Skip to content

Commit

Permalink
fix(outbound): hook_delivered may contain an IP, so..
Browse files Browse the repository at this point in the history
check mx.from_dns and if hostname is there, use that.
  • Loading branch information
msimerson committed Oct 2, 2024
1 parent bfd73e7 commit 9af3601
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion outbound/hmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const events = require('node:events');
const fs = require('node:fs');
const dns = require('node:dns');
const net = require('node:net');
const path = require('node:path');

const { Address } = require('address-rfc2821');
Expand Down Expand Up @@ -596,7 +597,13 @@ class HMailItem extends events.EventEmitter {
processing_mail = false;
if (success) {
const reason = response.join(' ');
self.delivered(host, port, (mx.using_lmtp ? 'LMTP' : 'SMTP'), mx.exchange,

let hostname = mx.exchange
if (net.isIP(hostname) && mx.from_dns && !net.isIP(mx.from_dns)) {
hostname = mx.from_dns
}

self.delivered(host, port, (mx.using_lmtp ? 'LMTP' : 'SMTP'), hostname,
reason, ok_recips, fail_recips, bounce_recips, secured, authenticated);
}
else {
Expand Down

0 comments on commit 9af3601

Please sign in to comment.