git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-send-email: Add AUTH LOGIN support

From
Joe Perches <joe@perches.com>
Date
Aug 6, 2011, 00:40 UTC
Message-ID
<c1be0c3bd05779897fdc92907fe65d84c88ac72b.1312591104.git.joe@perches.com>

The current perl Net::SMTP support will not use AUTH LOGIN when other authentication options are available.

Add an option to force the use of AUTH LOGIN when necessary. (Like when using my current hosted email server, grumble)

Signed-off-by: Joe Perches <joe@perches.com>
---
 Documentation/git-send-email.txt |    3 +++
 git-send-email.perl              |   19 +++++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 327233c..9595773 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -198,6 +198,9 @@ must be used for each option.
 	if a username is not specified (with '--smtp-user' or 'sendemail.smtpuser'),
 	then authentication is not attempted.
 
+--smtp-auth=<authorization_type>::
+	Force the smtp authentication to use a particular type.
+	Currently supported forced style is "login"
 
 Automating
 ~~~~~~~~~~
diff --git a/git-send-email.perl b/git-send-email.perl
index 98ab33a..37dfbe7 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -28,6 +28,7 @@ use File::Temp qw/ tempdir tempfile /;
 use File::Spec::Functions qw(catfile);
 use Error qw(:try);
 use Git;
+use MIME::Base64;
 
 Getopt::Long::Configure qw/ pass_through /;
 
@@ -193,7 +194,7 @@ sub do_edit {
 my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc);
 my ($to_cmd, $cc_cmd);
 my ($smtp_server, $smtp_server_port, @smtp_server_options);
-my ($smtp_authuser, $smtp_encryption);
+my ($smtp_authuser, $smtp_encryption, $smtp_auth);
 my ($identity, $aliasfiletype, @alias_files, $smtp_domain);
 my ($validate, $confirm);
 my (@suppress_cc);
@@ -218,6 +219,7 @@ my %config_settings = (
     "smtpserveroption" => \@smtp_server_options,
     "smtpuser" => \$smtp_authuser,
     "smtppass" => \$smtp_authpass,
+    "smtpauth" => \$smtp_auth,
     "smtpdomain" => \$smtp_domain,
     "to" => \@initial_to,
     "tocmd" => \$to_cmd,
@@ -293,6 +295,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "smtp-pass:s" => \$smtp_authpass,
 		    "smtp-ssl" => sub { $smtp_encryption = 'ssl' },
 		    "smtp-encryption=s" => \$smtp_encryption,
+		    "smtp-auth=s" => \$smtp_auth,
 		    "smtp-debug:i" => \$debug_net_smtp,
 		    "smtp-domain:s" => \$smtp_domain,
 		    "identity=s" => \$identity,
@@ -1111,7 +1114,19 @@ X-Mailer: git-send-email $gitversion
 				system "stty echo";
 			}
 
-			$auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
+			if (defined $smtp_auth && $smtp_auth =~ /^login$/i) {
+
+			    $smtp->datasend("AUTH LOGIN\n");
+			    $smtp->response();
+			    $smtp->datasend(encode_base64("$smtp_authuser"));
+			    $smtp->response();
+			    $smtp->datasend(encode_base64("$smtp_authpass"));
+			    $smtp->response();
+
+			} else {
+
+			    $auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
+			}
 		}
 
 		$smtp->mail( $raw_from ) or die $smtp->message;
-- 
1.7.6.131.g99019
Next: Junio C Hamano
Message 1 of 19 in “git-send-email: Add AUTH LOGIN support”
  1. git-send-email: Add AUTH LOGIN supportJoe Perches, Aug 6, 2011
  2. Junio C HamanoAug 6, 2011
  3. Joe PerchesAug 6, 2011
  4. Joe PerchesAug 19, 2011
  5. Junio C HamanoAug 19, 2011
  6. Joe PerchesAug 19, 2011
  7. Junio C HamanoAug 20, 2011
  8. send-email: auth plain/login fixZbigniew Jędrzejewski-Szmek, Sep 24, 2011
  9. Junio C HamanoSep 26, 2011
  10. Joe PerchesSep 26, 2011
  11. Jakub NarebskiSep 26, 2011
  12. send-email: auth plain/login fixZbigniew Jędrzejewski-Szmek, Sep 27, 2011
  13. Jeff KingSep 27, 2011
  14. send-email: auth plain/login fixZbigniew Jędrzejewski-Szmek, Sep 28, 2011
  15. Junio C HamanoSep 28, 2011
  16. send-email: auth plain/login fixZbigniew Jędrzejewski-Szmek, Sep 29, 2011
  17. Joe PerchesSep 29, 2011
  18. send-email: auth plain/login fixZbigniew Jędrzejewski-Szmek, Sep 29, 2011
  19. Junio C HamanoSep 29, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.