From 9af360115cceb0dc7817067de7e263360bc7d580 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 2 Oct 2024 10:15:58 -0700 Subject: [PATCH 1/2] fix(outbound): hook_delivered may contain an IP, so.. check mx.from_dns and if hostname is there, use that. --- outbound/hmail.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/outbound/hmail.js b/outbound/hmail.js index 62472e55f..677b65575 100644 --- a/outbound/hmail.js +++ b/outbound/hmail.js @@ -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'); @@ -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 { From cda0a4354905ef8156402f9057b49a7961565955 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 2 Oct 2024 10:20:14 -0700 Subject: [PATCH 2/2] update changes --- Changes.md | 4 ++++ outbound/hmail.js | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Changes.md b/Changes.md index 94dc8cca4..54cb5167c 100644 --- a/Changes.md +++ b/Changes.md @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Unreleased + +- fix(outbound): in outbound hook_delivered, when mx.exchange contains + an IP, use mx.from_dns + ### [3.0.5] - 2024-09-27 #### Fixed diff --git a/outbound/hmail.js b/outbound/hmail.js index 677b65575..65626da9e 100644 --- a/outbound/hmail.js +++ b/outbound/hmail.js @@ -598,10 +598,10 @@ class HMailItem extends events.EventEmitter { if (success) { const reason = response.join(' '); - let hostname = mx.exchange - if (net.isIP(hostname) && mx.from_dns && !net.isIP(mx.from_dns)) { - hostname = mx.from_dns - } + 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);