Subject: Re: [PATCH v6 1/1] send-email: retrieve Message-ID from outlook SMTP server

From: Junio C Hamano <[email-masked]>
Date: Fri, 25 Apr 2025 10:23:11 -0700

Aditya Garg <[email-masked]> writes:

> +sub is_outlook {
> +	my ($host) = @_;
> +	return ($host eq 'smtp.office365.com' || $host eq 'smtp-mail.outlook.com');
> +}

There were a few messages that raised concerns with respect to
on-prem installations of Outlook based servers, where the hostname
cannot be used to tell if we need this message-id tweaking.

The following is a completely untested patch, but it should be
sufficient to illustrate how simple it would be to support an
option to do so, if we cared about the issue enough.

Will queue your patch _without_ this tweak, at least for now.

Thanks.

 git-send-email.perl | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git c/git-send-email.perl w/git-send-email.perl
index 618474916e..dff3d861e4 100755
--- c/git-send-email.perl
+++ w/git-send-email.perl
@@ -60,6 +60,7 @@ sub usage {
     --smtp-user             <str>  * Username for SMTP-AUTH.
     --smtp-pass             <str>  * Password for SMTP-AUTH; not necessary.
     --smtp-encryption       <str>  * tls or ssl; anything else disables.
+    --smtp-outlook-id-tweak <0|1>  * The server munges Message-ID.
     --smtp-ssl                     * Deprecated. Use '--smtp-encryption ssl'.
     --smtp-ssl-cert-path    <str>  * Path to ca-certificates (either directory or file).
                                      Pass an empty string to disable certificate
@@ -290,6 +291,7 @@ sub do_edit {
 my $mailmap = 0;
 my $target_xfer_encoding = 'auto';
 my $forbid_sendmail_variables = 1;
+my $outlook_id_tweak = -1; # we need to tell --no-opt and lack of it
 
 my %config_bool_settings = (
     "thread" => \$thread,
@@ -305,6 +307,7 @@ sub do_edit {
     "xmailer" => \$use_xmailer,
     "forbidsendmailvariables" => \$forbid_sendmail_variables,
     "mailmap" => \$mailmap,
+    "outlookidtweak" => \$outlook_id_tweak,
 );
 
 my %config_settings = (
@@ -518,6 +521,7 @@ sub config_regexp {
 		    "smtp-pass:s" => \$smtp_authpass,
 		    "smtp-ssl" => sub { $smtp_encryption = 'ssl' },
 		    "smtp-encryption=s" => \$smtp_encryption,
+		    "smtp-outlook-id-tweak!" => \$outlook_id_tweak,
 		    "smtp-ssl-cert-path=s" => \$smtp_ssl_cert_path,
 		    "smtp-debug:i" => \$debug_net_smtp,
 		    "smtp-domain:s" => \$smtp_domain,
@@ -1576,7 +1580,13 @@ sub gen_header {
 
 sub is_outlook {
 	my ($host) = @_;
-	return ($host eq 'smtp.office365.com' || $host eq 'smtp-mail.outlook.com');
+
+	if ($outlook_id_tweak < 0) {
+		$outlook_id_tweak = 
+		    ($host eq 'smtp.office365.com' ||
+		     $host eq 'smtp-mail.outlook.com') ? 1 : 0;
+	}
+	return $outlook_id_tweak;
 }
 
 # Prepares the email, then asks the user what to do.