send-email: add --[no-]outlook-id-fix option

Add an option to allow users to specifically enable or disable retrieving the Message-ID from the Outlook SMTP server. This can be used for other hosts mimicking the behaviour of Outlook, or for users who set a custom domain to be a CNAME for the Outlook SMTP server. While at it, lets also add missing * in description of --no-smtp-auth. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Aditya Garg <gargaditya08@live.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Aditya Garg committed Apr 29, 2025 at 16:37 UTC daec3c08e3e40c436cab013c5005a6e8b2e7923e
2 files changed +25 -2
Documentation/git-send-email.adoc
+13
@@ -115,6 +115,19 @@ illustration below where `[PATCH v2 0/3]` is in reply to `[PATCH 0/2]`:
115 Only necessary if --compose is also set. If --compose
116 is not set, this will be prompted for.
117
118 +--[no-]outlook-id-fix::
119 + Microsoft Outlook SMTP servers discard the Message-ID sent via email and
120 + assign a new random Message-ID, thus breaking threads.
121 ++
122 +With `--outlook-id-fix`, 'git send-email' uses a mechanism specific to
123 +Outlook servers to learn the Message-ID the server assigned to fix the
124 +threading. Use it only when you know that the server reports the
125 +rewritten Message-ID the same way as Outlook servers do.
126 ++
127 +Without this option specified, the fix is done by default when talking
128 +to 'smtp.office365.com' or 'smtp-mail.outlook.com'. Use
129 +`--no-outlook-id-fix` to disable even when talking to these two servers.
130 +
131 --subject=<string>::
132 Specify the initial subject of the email thread.
133 Only necessary if --compose is also set. If --compose
git-send-email.perl
+12 -2
@@ -41,6 +41,8 @@ git send-email --translate-aliases
41 --subject <str> * Email "Subject:"
42 --reply-to <str> * Email "Reply-To:"
43 --in-reply-to <str> * Email "In-Reply-To:"
44 + --[no-]outlook-id-fix * The SMTP host is an Outlook server that munges the
45 + Message-ID. Retrieve it from the server.
46 --[no-]xmailer * Add "X-Mailer:" header (default).
47 --[no-]annotate * Review each patch that will be sent in an editor.
48 --compose * Open an editor for introduction.
@@ -68,7 +70,7 @@ git send-email --translate-aliases
70 --smtp-auth <str> * Space-separated list of allowed AUTH mechanisms, or
71 "none" to disable authentication.
72 This setting forces to use one of the listed mechanisms.
71 - --no-smtp-auth Disable SMTP authentication. Shorthand for
73 + --no-smtp-auth * Disable SMTP authentication. Shorthand for
74 `--smtp-auth=none`
75 --smtp-debug <0|1> * Disable, enable Net::SMTP debug.
76
@@ -290,6 +292,7 @@ my $validate = 1;
292 my $mailmap = 0;
293 my $target_xfer_encoding = 'auto';
294 my $forbid_sendmail_variables = 1;
295 +my $outlook_id_fix = 'auto';
296
297 my %config_bool_settings = (
298 "thread" => \$thread,
@@ -305,6 +308,7 @@ my %config_bool_settings = (
308 "xmailer" => \$use_xmailer,
309 "forbidsendmailvariables" => \$forbid_sendmail_variables,
310 "mailmap" => \$mailmap,
311 + "outlookidfix" => \$outlook_id_fix,
312 );
313
314 my %config_settings = (
@@ -551,6 +555,7 @@ my %options = (
555 "relogin-delay=i" => \$relogin_delay,
556 "git-completion-helper" => \$git_completion_helper,
557 "v=s" => \$reroll_count,
558 + "outlook-id-fix!" => \$outlook_id_fix,
559 );
560 $rc = GetOptions(%options);
561
@@ -1576,7 +1581,12 @@ Message-ID: $message_id
1581
1582 sub is_outlook {
1583 my ($host) = @_;
1579 - return ($host eq 'smtp.office365.com' || $host eq 'smtp-mail.outlook.com');
1584 + if ($outlook_id_fix eq 'auto') {
1585 + $outlook_id_fix =
1586 + ($host eq 'smtp.office365.com' ||
1587 + $host eq 'smtp-mail.outlook.com') ? 1 : 0;
1588 + }
1589 + return $outlook_id_fix;
1590 }
1591
1592 # Prepares the email, then asks the user what to do.