]> git.ipfire.org Git - thirdparty/git.git/commitdiff
send-email: show the new message id assigned by outlook in the logs
authorAditya Garg <gargaditya08@live.com>
Wed, 4 Jun 2025 12:55:14 +0000 (18:25 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Jun 2025 16:30:13 +0000 (09:30 -0700)
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

Fix this by updating the $header variable, which has the message ID we
internally assigned on the "Message-ID:" header, with the message ID the
Outlook server assigned. 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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-send-email.perl

index 5bf4307442b57cf8d653891147e7cfbd6d028a8a..cb6dca2500c93f75642fae3194f496464a378cf2 100755 (executable)
@@ -1788,7 +1788,8 @@ EOF
                if (is_outlook($smtp_server)) {
                        if ($smtp->message =~ /<([^>]+)>/) {
                                $message_id = "<$1>";
-                               printf __("Outlook reassigned Message-ID to: %s\n"), $message_id;
+                               $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");
                        }