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@xxxxxxxx> --- git-send-email.perl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/git-send-email.perl b/git-send-email.perl index aa6aad596f..f2a926872d 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -1799,6 +1799,17 @@ sub send_message { $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) { -- 2.49.0