git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-send-email: Add AUTH LOGIN support
@ 2011-08-06  0:40 Joe Perches
  2011-08-06  4:54 ` Junio C Hamano
  0 siblings, 1 reply; 19+ messages in thread
From: Joe Perches @ 2011-08-06  0:40 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-09-29 18:12 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-06  0:40 [PATCH] git-send-email: Add AUTH LOGIN support Joe Perches
2011-08-06  4:54 ` Junio C Hamano
2011-08-06  5:21   ` Joe Perches
2011-08-19  1:16     ` Joe Perches
2011-08-19 23:09       ` Junio C Hamano
2011-08-19 23:24         ` Joe Perches
2011-08-20  1:01           ` Junio C Hamano
2011-09-24 15:49   ` [PATCH] send-email: auth plain/login fix Zbigniew Jędrzejewski-Szmek
2011-09-26 16:38     ` Junio C Hamano
2011-09-26 16:59       ` Joe Perches
2011-09-26 17:24     ` Jakub Narebski
2011-09-27 21:36       ` [PATCH v2] " Zbigniew Jędrzejewski-Szmek
2011-09-27 21:48         ` Jeff King
2011-09-28 10:26       ` [PATCH v3] " Zbigniew Jędrzejewski-Szmek
2011-09-28 22:00         ` Junio C Hamano
2011-09-29 14:16           ` [PATCH v4] " Zbigniew Jędrzejewski-Szmek
2011-09-29 15:01             ` Joe Perches
2011-09-29 17:02               ` [PATCH] " Zbigniew Jędrzejewski-Szmek
2011-09-29 18:12                 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).