From: "Aditya Garg via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: M Hickford <mirth.hickford@gmail.com>,
Julian Swagemakers <julian@swagemakers.org>,
sandals@crustytoothpaste.net, Shengyu Qu <wiagn233@outlook.com>,
Aditya Garg <gargaditya08@live.com>,
Aditya Garg <gargaditya08@live.com>
Subject: [PATCH 2/2] send-email: retrieve Message-ID from outlook SMTP server
Date: Tue, 22 Apr 2025 07:19:10 +0000 [thread overview]
Message-ID: <00e1be73ab91db1c37447544ebcdc4f33432dbcb.1745306351.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1949.git.git.1745306351.gitgitgadget@gmail.com>
From: Aditya Garg <gargaditya08@live.com>
Outlook does not accept the Message-ID header in the email body. Instead
it saves it in its own proprietary X-Microsoft-Original-Message-ID
header and a random Message-ID is set my the server. As a result,
replying to threads does not work.
The $smtp->message variable in this script for outlook is something like
this:
2.0.0 OK <Message-ID> [Hostname=Some-hostname]
This contains the Message-ID set by Microsoft in the first <>.
This patch retrieves the Message-ID from this server response
and sets it in the email headers instead of using the self generated one.
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
git-send-email.perl | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/git-send-email.perl b/git-send-email.perl
index aa6aad596f2..f2a926872de 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1799,6 +1799,17 @@ EOF
$smtp->datasend("$line") or die $smtp->message;
}
$smtp->dataend() or die $smtp->message;
+
+ # Retrieve the Message-ID from the server response in case of Outlook
+ if ($smtp_server eq 'smtp.office365.com' || $smtp_server eq 'smtp-mail.outlook.com') {
+ if ($smtp->message =~ /<([^>]+)>/) {
+ $message_id = "<$1>";
+ print __("Outlook: Retrieved Message-ID: $message_id\n");
+ } else {
+ warn __("Warning: Could not retrieve Message-ID from server response.\n");
+ }
+ }
+
$smtp->code =~ /250|200/ or die sprintf(__("Failed to send %s\n"), $subject).$smtp->message;
}
if ($quiet) {
--
gitgitgadget
next prev parent reply other threads:[~2025-04-22 7:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 7:19 [PATCH 0/2] Ad support for Oauth2 and fix message-id bug in outlook Aditya Garg via GitGitGadget
2025-04-22 7:19 ` [PATCH 1/2] send-email: implement SMTP bearer authentication Julian Swagemakers via GitGitGadget
2025-04-22 7:19 ` Aditya Garg via GitGitGadget [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-04-22 6:54 [PATCH 0/2] send-email: add oauth2 support and fix outlook breaking threads Aditya Garg
2025-04-22 6:55 ` [PATCH 2/2] send-email: retrieve Message-ID from outlook SMTP server Aditya Garg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=00e1be73ab91db1c37447544ebcdc4f33432dbcb.1745306351.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=gargaditya08@live.com \
--cc=git@vger.kernel.org \
--cc=julian@swagemakers.org \
--cc=mirth.hickford@gmail.com \
--cc=sandals@crustytoothpaste.net \
--cc=wiagn233@outlook.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.