git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v6 2/2] send-email: show the new message id assigned by outlook in the logs

From
Aditya Garg <gargaditya08@live.com>
Date
May 29, 2025, 14:57 UTC
Message-ID
<caf46596a709df7205495b75da569baef2c7c9a2.1748529954.git.gargaditya08@live.com>
In-Reply-To
<cover.1748529954.git.gargaditya08@live.com>

Whenever an email is sent, send-email shows a log at last, which contains all the headers of the email that were received by the receipients.

In case outlook changes the Message-ID, a log for the same is shown to the user, but that change is not reflected when the log containing all the headers is displayed. Here is an example of the log that is shown when outlook changes the Message-ID:

Outlook reassigned Message-ID to: <PN3PR01MB95973E5ACD7CCFADCB4E298CB865A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
OK. Log says:
Server: smtp.office365.com
MAIL FROM:<gargaditya08@live.com>
RCPT TO:<negahe7142@nomrista.com>
From: Aditya Garg <gargaditya08@live.com>
To: negahe7142@nomrista.com
Subject: [PATCH] send-email: show the new message id assigned by outlook in the logs
Date: Mon, 26 May 2025 20:28:36 +0530
Message-ID: <20250526145836.4825-1-gargaditya08@live.com>
X-Mailer: git-send-email @GIT_VERSION@
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Result: 250

This patch fixes this by modifying the $header variable, which is responsible for showing the logs at the end. Also, the log which states that the Message-ID has been changed will now be shown only when smtp-debug is enabled, since the main log having all of the headers is anyways displaying the new Message-ID. It should look like this after this patch:

OK. Log says:
Server: smtp.office365.com
MAIL FROM:<gargaditya08@live.com>
RCPT TO:<negahe7142@nomrista.com>
From: Aditya Garg <gargaditya08@live.com>
To: negahe7142@nomrista.com
Subject: [PATCH] send-email: show the new message id assigned by outlook in the logs
Date: Mon, 26 May 2025 20:29:22 +0530
Message-ID: <PN3PR01MB95977486061BD2542BD09B67B865A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
X-Mailer: git-send-email @GIT_VERSION@
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Result: 250
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 git-send-email.perl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index ac1d5b7070..79d230448f 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1774,7 +1774,9 @@ sub send_message {
 		if (is_outlook($smtp_server)) {
 			if ($smtp->message =~ /<([^>]+)>/) {
 				$message_id = "<$1>";
-				printf __("Outlook reassigned Message-ID to: %s\n"), $message_id;
+				# Replace the original Message-ID in $header with the new one
+				$header =~ s/^(Message-ID:\s*).*\n/${1}$message_id\n/m;
+				printf __("Outlook reassigned Message-ID to: %s\n"), $message_id if $smtp->debug;
 			} else {
 				warn __("Warning: Could not retrieve Message-ID from server response.\n");
 			}
-- 
2.49.0.635.g48fa2f4343
Previous: Aditya GargNext: Junio C Hamano
Message 6 of 14 in “send-email: fix threads breaking in case user edits emails and improvements to outlook ID fix.”
  1. 0/2 send-email: fix threads breaking in case user edits emails and improvements to outlook ID fix.Aditya Garg, May 26, 2025
  2. 1/2 send-email: fix bug resulting in increased message number if a message is editedAditya Garg, May 26, 2025
  3. 2/2 send-email: show the new message id assigned by outlook in the logsAditya Garg, May 26, 2025
  4. 0/2 send-email: fix threads breaking in case user edits emails and improvements to outlook ID fix.Aditya Garg, May 29, 2025
  5. 1/2 send-email: fix bug resulting in broken threads if a message is editedAditya Garg, May 29, 2025
  6. 2/2 send-email: show the new message id assigned by outlook in the logsAditya Garg, May 29, 2025
  7. Junio C HamanoMay 29, 2025
  8. Aditya GargMay 29, 2025
  9. Junio C HamanoJun 4, 2025
  10. Aditya GargJun 4, 2025
  11. 0/2 send-email: fix threads breaking in case user edits emails and improvements to outlook ID fix.Aditya Garg, Jun 4, 2025
  12. 2/2 send-email: show the new message id assigned by outlook in the logsAditya Garg, Jun 4, 2025
  13. 1/2 send-email: fix bug resulting in broken threads if a message is editedAditya Garg, Jun 4, 2025
  14. Junio C HamanoJun 4, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.