threads / patch / 65139

patchsend-email: pass smtp hostname and port to Authen::SASL

Subject: [PATCH] send-email: pass smtp hostname and port to Authen::SASL

## tl;dr

6 messages between Mar 5, 2026 and Mar 5, 2026. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

Aditya Garg· Mar 5, 2026, 12:06 UTC · lore

Starting from version 2.2000, Authen::SASL supports passing the SMTP server hostname and port to the OAUTHBEARER string passed via SMTP AUTH. Add support for the same in git-send-email.

Link: https://metacpan.org/pod/Authen::SASL::Perl::OAUTHBEARER
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 git-send-email.perl | 2 ++
 1 file changed, 2 insertions(+)
Show changes to git-send-email.perl +2 −0
diff --git a/git-send-email.perl b/git-send-email.perl
index eed5420882..0ac4d634e8 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1474,6 +1474,8 @@ sub smtp_auth_maybe {
 						user     => $cred->{'username'},
 						pass     => $cred->{'password'},
 						authname => $cred->{'username'},
+						host     => $smtp_server,
+						(defined $smtp_server_port ? (port => $smtp_server_port) : ()),
 					}
 				);
 				$result = $smtp->auth($sasl);
-- 
2.52.0
Junio C Hamano· Mar 5, 2026, 14:44 UTC · re: Aditya Garg · lore

Re: [PATCH] send-email: pass smtp hostname and port to Authen::SASL

Aditya Garg <gargaditya08@live.com> writes:
[administrivia]
    Please do not send patch e-mails directly at me, unless you know
    that I am the area authority.  Initial submissions are better
    sent to the list on To: list, with area experts on Cc: if you
    know or found out who they are.
> Starting from version 2.2000, Authen::SASL supports passing the SMTP
> server hostname and port to the OAUTHBEARER string passed via SMTP AUTH.
> Add support for the same in git-send-email.
The proposed log message should answer these questions as well:
   What happens with version before 2.2000?  Is it safe to
   unconditionally add parameters like this patch does, and why?
Show 20 quoted lines
> Link: https://metacpan.org/pod/Authen::SASL::Perl::OAUTHBEARER
>
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> ---
>  git-send-email.perl | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index eed5420882..0ac4d634e8 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -1474,6 +1474,8 @@ sub smtp_auth_maybe {
>  						user     => $cred->{'username'},
>  						pass     => $cred->{'password'},
>  						authname => $cred->{'username'},
> +						host     => $smtp_server,
> +						(defined $smtp_server_port ? (port => $smtp_server_port) : ()),
>  					}
>  				);
>  				$result = $smtp->auth($sasl);
Thanks.
Aditya Garg· Mar 5, 2026, 15:14 UTC · re: Junio C Hamano · lore

Re: [PATCH] send-email: pass smtp hostname and port to Authen::SASL

Show 10 quoted lines
> On 5 Mar 2026, at 8:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
> 
> Aditya Garg <gargaditya08@live.com> writes:
> 
> [administrivia]
> 
>    Please do not send patch e-mails directly at me, unless you know
>    that I am the area authority.  Initial submissions are better
>    sent to the list on To: list, with area experts on Cc: if you
>    know or found out who they are.
Oh sorry. I just did whatever I did in my previous contributions. I didn't know the rules changed.
Will mail just the mailing list next time.
Show 9 quoted lines
> 
>> Starting from version 2.2000, Authen::SASL supports passing the SMTP
>> server hostname and port to the OAUTHBEARER string passed via SMTP AUTH.
>> Add support for the same in git-send-email.
> 
> The proposed log message should answer these questions as well:
> 
>   What happens with version before 2.2000?  Is it safe to
>   unconditionally add parameters like this patch does, and why?
It's safe to add parameters unconditionally because the library will simply reject them without any error. It's basically like declaring a variable and not using it anywhere for older versions. I have tested this with old libraries as well.
Consider the fact that the authname variable is also not in every authentication method used by Authen SASL, still its declared unconditionally before.
Show 23 quoted lines
> 
>> Link: https://metacpan.org/pod/Authen::SASL::Perl::OAUTHBEARER
>> 
>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>> ---
>> git-send-email.perl | 2 ++
>> 1 file changed, 2 insertions(+)
>> 
>> diff --git a/git-send-email.perl b/git-send-email.perl
>> index eed5420882..0ac4d634e8 100755
>> --- a/git-send-email.perl
>> +++ b/git-send-email.perl
>> @@ -1474,6 +1474,8 @@ sub smtp_auth_maybe {
>>                        user     => $cred->{'username'},
>>                        pass     => $cred->{'password'},
>>                        authname => $cred->{'username'},
>> +                        host     => $smtp_server,
>> +                        (defined $smtp_server_port ? (port => $smtp_server_port) : ()),
>>                    }
>>                );
>>                $result = $smtp->auth($sasl);
> 
> Thanks.
Junio C Hamano· Mar 5, 2026, 16:24 UTC · re: Aditya Garg · lore

Re: [PATCH] send-email: pass smtp hostname and port to Authen::SASL

Aditya Garg <gargaditya08@live.com> writes:
Show 12 quoted lines
>> On 5 Mar 2026, at 8:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> 
>> Aditya Garg <gargaditya08@live.com> writes:
>> 
>> [administrivia]
>> 
>>    Please do not send patch e-mails directly at me, unless you know
>>    that I am the area authority.  Initial submissions are better
>>    sent to the list on To: list, with area experts on Cc: if you
>>    know or found out who they are.
>
> Oh sorry. I just did whatever I did in my previous contributions. I didn't know the rules changed.
No rule changes as far as I know.
Show 17 quoted lines
>>> Starting from version 2.2000, Authen::SASL supports passing the SMTP
>>> server hostname and port to the OAUTHBEARER string passed via SMTP AUTH.
>>> Add support for the same in git-send-email.
>> 
>> The proposed log message should answer these questions as well:
>> 
>>   What happens with version before 2.2000?  Is it safe to
>>   unconditionally add parameters like this patch does, and why?
>
> It's safe to add parameters unconditionally because the library
> will simply reject them without any error. It's basically like
> declaring a variable and not using it anywhere for older
> versions. I have tested this with old libraries as well.
>
> Consider the fact that the authname variable is also not in every
> authentication method used by Authen SASL, still its declared
> unconditionally before.
These are good to have in the proposed log message.
Thanks.
Aditya Garg· Mar 5, 2026, 16:54 UTC · re: Junio C Hamano · lore

Re: [PATCH] send-email: pass smtp hostname and port to Authen::SASL

On 05/03/26 9:54 pm, Junio C Hamano wrote:
Show 16 quoted lines
> Aditya Garg <gargaditya08@live.com> writes:
> 
>>> On 5 Mar 2026, at 8:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>>
>>> Aditya Garg <gargaditya08@live.com> writes:
>>>
>>> [administrivia]
>>>
>>>    Please do not send patch e-mails directly at me, unless you know
>>>    that I am the area authority.  Initial submissions are better
>>>    sent to the list on To: list, with area experts on Cc: if you
>>>    know or found out who they are.
>>
>> Oh sorry. I just did whatever I did in my previous contributions. I didn't know the rules changed.
> 
> No rule changes as far as I know.
I had sent several patches for send-email and imap-send between 2.50 and 2.52, and in every submission I did email directly to the maintainers. Maybe you were just lenient with me that time. Regardless, I'll make sure that future patches are sent only to the mailing list.
Show 20 quoted lines
> 
>>>> Starting from version 2.2000, Authen::SASL supports passing the SMTP
>>>> server hostname and port to the OAUTHBEARER string passed via SMTP AUTH.
>>>> Add support for the same in git-send-email.
>>>
>>> The proposed log message should answer these questions as well:
>>>
>>>   What happens with version before 2.2000?  Is it safe to
>>>   unconditionally add parameters like this patch does, and why?
>>
>> It's safe to add parameters unconditionally because the library
>> will simply reject them without any error. It's basically like
>> declaring a variable and not using it anywhere for older
>> versions. I have tested this with old libraries as well.
>>
>> Consider the fact that the authname variable is also not in every
>> authentication method used by Authen SASL, still its declared
>> unconditionally before.
> 
> These are good to have in the proposed log message.
Will send a v2
Cheers!
Aditya Garg· Mar 5, 2026, 17:01 UTC · re: Aditya Garg · lore

[PATCH v2] send-email: pass smtp hostname and port to Authen::SASL

Starting from version 2.2000, Authen::SASL supports passing the SMTP server hostname and port to the OAUTHBEARER string passed via SMTP AUTH. Add support for the same in git-send-email.

It's safe to add the new parameters unconditionally as older versions of Authen::SASL will simply ignore them without any error. Something similar is already being done for the authname parameter, which is not supported by every authentication mechanism. This can be understood as declaring a variable but not using at all.

Link: https://metacpan.org/pod/Authen::SASL::Perl::OAUTHBEARER
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 git-send-email.perl | 2 ++
 1 file changed, 2 insertions(+)
Show changes to git-send-email.perl +2 −0
diff --git a/git-send-email.perl b/git-send-email.perl
index eed5420882..0ac4d634e8 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1474,6 +1474,8 @@ sub smtp_auth_maybe {
 						user     => $cred->{'username'},
 						pass     => $cred->{'password'},
 						authname => $cred->{'username'},
+						host     => $smtp_server,
+						(defined $smtp_server_port ? (port => $smtp_server_port) : ()),
 					}
 				);
 				$result = $smtp->auth($sasl);

Range-diff against v1:
1:  9b48ca57ae ! 1:  5befaa626d send-email: pass smtp hostname and port to Authen::SASL
    @@ Commit message
         server hostname and port to the OAUTHBEARER string passed via SMTP AUTH.
         Add support for the same in git-send-email.
     
    +    It's safe to add the new parameters unconditionally as older versions of
    +    Authen::SASL will simply ignore them without any error. Something
    +    similar is already being done for the authname parameter, which is not
    +    supported by every authentication mechanism. This can be understood as
    +    declaring a variable but not using at all.
    +
         Link: https://metacpan.org/pod/Authen::SASL::Perl::OAUTHBEARER
     
         Signed-off-by: Aditya Garg <gargaditya08@live.com>
-- 
2.52.0

← back to recent threads