Skip to content

Commit 8dd9b3f

Browse files
JPEWdevgitster
authored andcommitted
send-email: explicitly disable authentication
It can be necessary to disable SMTP authentication by a mechanism other than sendemail.smtpuser being undefined. For example, if the user has sendemail.smtpuser set globally but wants to disable authentication locally in one repository. --smtp-auth and sendemail.smtpauth now understand the value 'none' which means to disable authentication completely, even if an authentication user is specified. The value 'none' is lower case to avoid conflicts with any RFC 4422 authentication mechanisms. The user may also specify the command line argument --no-smtp-auth as a shorthand for --smtp-auth=none Signed-off-by: Joshua Watt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c4df23f commit 8dd9b3f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Documentation/git-send-email.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ $ git send-email --smtp-auth="PLAIN LOGIN GSSAPI" ...
190190
If at least one of the specified mechanisms matches the ones advertised by the
191191
SMTP server and if it is supported by the utilized SASL library, the mechanism
192192
is used for authentication. If neither 'sendemail.smtpAuth' nor `--smtp-auth`
193-
is specified, all mechanisms supported by the SASL library can be used.
193+
is specified, all mechanisms supported by the SASL library can be used. The
194+
special value 'none' maybe specified to completely disable authentication
195+
independently of `--smtp-user`
194196

195197
--smtp-pass[=<password>]::
196198
Password for SMTP-AUTH. The argument is optional: If no
@@ -204,6 +206,9 @@ or on the command line. If a username has been specified (with
204206
specified (with `--smtp-pass` or `sendemail.smtpPass`), then
205207
a password is obtained using 'git-credential'.
206208

209+
--no-smtp-auth::
210+
Disable SMTP authentication. Short hand for `--smtp-auth=none`
211+
207212
--smtp-server=<host>::
208213
If set, specifies the outgoing SMTP server to use (e.g.
209214
`smtp.example.com` or a raw IP address). Alternatively it can

git-send-email.perl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ sub usage {
8282
Pass an empty string to disable certificate
8383
verification.
8484
--smtp-domain <str> * The domain name sent to HELO/EHLO handshake
85-
--smtp-auth <str> * Space-separated list of allowed AUTH mechanisms.
85+
--smtp-auth <str> * Space-separated list of allowed AUTH mechanisms, or
86+
"none" to disable authentication.
8687
This setting forces to use one of the listed mechanisms.
88+
--no-smtp-auth Disable SMTP authentication. Shorthand for
89+
`--smtp-auth=none`
8790
--smtp-debug <0|1> * Disable, enable Net::SMTP debug.
8891
8992
--batch-size <int> * send max <int> message per connection.
@@ -341,6 +344,7 @@ sub signal_handler {
341344
"smtp-debug:i" => \$debug_net_smtp,
342345
"smtp-domain:s" => \$smtp_domain,
343346
"smtp-auth=s" => \$smtp_auth,
347+
"no-smtp-auth" => sub {$smtp_auth = 'none'},
344348
"identity=s" => \$identity,
345349
"annotate!" => \$annotate,
346350
"no-annotate" => sub {$annotate = 0},
@@ -1241,7 +1245,7 @@ sub smtp_host_string {
12411245
# (smtp_user was not specified), and 0 otherwise.
12421246

12431247
sub smtp_auth_maybe {
1244-
if (!defined $smtp_authuser || $auth) {
1248+
if (!defined $smtp_authuser || $auth || (defined $smtp_auth && $smtp_auth eq "none")) {
12451249
return 1;
12461250
}
12471251

0 commit comments

Comments
 (0)