haraka / Haraka

A fast, highly extensible, and event driven SMTP server

Home Page:https://haraka.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gmail problem with empty Message-id

jan-panoch opened this issue · comments

Describe the bug

I found a problem with delivering mail to gmail when Message-id header is present, but empty <>. we get for example
following response:

bounced - 550 5.7.1 [89.22.67.15] Messages missing a valid messageId header are not accepted. lw15-20020a170906bccf00b00992dc9d3b33si10406355ejb.863 - gsmtp

Expected behavior

Delivering mail.

Observed behavior

Mail is bounced.

Steps To Reproduce

Share calendar event from mac to gmail-handled email.

System Info:

Haraka Haraka.js — Version: 3.0.1
Node v19.9.0
OS Linux ms.dacc.cz 4.19.0-23-amd64 #1 SMP Debian 4.19.269-1 (2022-12-20) x86_64 GNU/Linux
openssl OpenSSL 1.1.1n 15 Mar 2022

Additional context

I suggest to modify outbound/index.js adding following code (diff):

--- Haraka-orig/outbound/index.js	2023-09-08 08:25:07.869872111 +0200
+++ Haraka/outbound/index.js	2023-09-08 08:42:28.146499805 +0200
@@ -226,6 +226,11 @@
         logger.loginfo("[outbound] Adding missing Message-Id header");
         transaction.add_header('Message-Id', `<${transaction.uuid}@${net_utils.get_primary_host_name()}>`);
     }
+    if (transaction.header.get('Message-Id') === '<>') {
+        logger.loginfo("[outbound] Replacing empty Message-Id header");
+        transaction.remove_header('Message-Id');
+        transaction.add_header('Message-Id', `<${transaction.uuid}@${net_utils.get_primary_host_name()}>`);
+    }
     if (!transaction.header.get_all('Date').length) {
         logger.loginfo("[outbound] Adding missing Date header");
         transaction.add_header('Date', utils.date_to_str(new Date()));

btw confirmed as working, with added Message-ID this way gmail is accepting those emails without problems.