git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add support for SMTP server options
@ 2010-09-04 16:06 Pascal Obry
  2010-09-04 16:06 ` [PATCH 1/2] Minor indentation fix Pascal Obry
  2010-09-04 16:06 ` [PATCH 2/2] New send-email option smtpserveroptions Pascal Obry
  0 siblings, 2 replies; 6+ messages in thread
From: Pascal Obry @ 2010-09-04 16:06 UTC (permalink / raw)
  To: git; +Cc: Pascal Obry

I'm not familiar at all with Perl so comments on style or usage most
welcomed. This patch is to introduce a way to pass specific options to the
SMTP server used by git-send-email.

I need that to be able to use different SMTP account (wanadoo, gmail...) on
some Git repositories to send over proper identity.

Pascal Obry (2):
  Minor indentation fix.
  New send-email option smtpserveroptions.

 Documentation/git-send-email.txt |    5 +++++
 git-send-email.perl              |   11 +++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

-- 
1.7.2.2.277.gb49c4

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

* [PATCH 1/2] Minor indentation fix.
  2010-09-04 16:06 [PATCH 0/2] Add support for SMTP server options Pascal Obry
@ 2010-09-04 16:06 ` Pascal Obry
  2010-09-04 16:06 ` [PATCH 2/2] New send-email option smtpserveroptions Pascal Obry
  1 sibling, 0 replies; 6+ messages in thread
From: Pascal Obry @ 2010-09-04 16:06 UTC (permalink / raw)
  To: git; +Cc: Pascal Obry

---
 git-send-email.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 6dab3bf..0063606 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -212,7 +212,7 @@ my %config_settings = (
     "smtpserverport" => \$smtp_server_port,
     "smtpuser" => \$smtp_authuser,
     "smtppass" => \$smtp_authpass,
-	"smtpdomain" => \$smtp_domain,
+    "smtpdomain" => \$smtp_domain,
     "to" => \@to,
     "cc" => \@initial_cc,
     "cccmd" => \$cc_cmd,
-- 
1.7.2.2.277.gb49c4

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

* [PATCH 2/2] New send-email option smtpserveroptions.
  2010-09-04 16:06 [PATCH 0/2] Add support for SMTP server options Pascal Obry
  2010-09-04 16:06 ` [PATCH 1/2] Minor indentation fix Pascal Obry
@ 2010-09-04 16:06 ` Pascal Obry
  2010-09-04 16:21   ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Pascal Obry @ 2010-09-04 16:06 UTC (permalink / raw)
  To: git; +Cc: Pascal Obry

The new command line parameter --smtp-server-options or default
configuration sendemail.smtpserveroptions can be used to pass
specific options to the SMTP server.
---
 Documentation/git-send-email.txt |    5 +++++
 git-send-email.perl              |    9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index c283084..425b102 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -157,6 +157,11 @@ user is prompted for a password while the input is masked for privacy.
 	`/usr/lib/sendmail` if such program is available, or
 	`localhost` otherwise.
 
+--smtp-server-options=<options>::
+	If set, specifies the outgoing SMTP server options to use.
+	Default value can be specified by the 'sendemail.smtpserveroptions'
+	configuration option.
+
 --smtp-server-port=<port>::
 	Specifies a port different from the default port (SMTP
 	servers typically listen to smtp port 25, but may also listen to
diff --git a/git-send-email.perl b/git-send-email.perl
index 0063606..e5cdda7 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -60,6 +60,7 @@ git send-email [options] <file | directory | rev-list options >
     --envelope-sender       <str>  * Email envelope sender.
     --smtp-server       <str:int>  * Outgoing SMTP server to use. The port
                                      is optional. Default 'localhost'.
+    --smtp-server-options   <int>  * Outgoing SMTP server options to use.
     --smtp-server-port      <int>  * Outgoing SMTP server port.
     --smtp-user             <str>  * Username for SMTP-AUTH.
     --smtp-pass             <str>  * Password for SMTP-AUTH; not necessary.
@@ -188,7 +189,8 @@ sub do_edit {
 
 # Variables with corresponding config settings
 my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
-my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
+my ($smtp_server, $smtp_server_port, $smtp_server_options);
+my ($smtp_authuser, $smtp_encryption);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain);
 my ($validate, $confirm);
 my (@suppress_cc);
@@ -210,6 +212,7 @@ my %config_bool_settings = (
 my %config_settings = (
     "smtpserver" => \$smtp_server,
     "smtpserverport" => \$smtp_server_port,
+    "smtpserveroptions" => \$smtp_server_options,
     "smtpuser" => \$smtp_authuser,
     "smtppass" => \$smtp_authpass,
     "smtpdomain" => \$smtp_domain,
@@ -279,6 +282,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "no-bcc" => \$no_bcc,
 		    "chain-reply-to!" => \$chain_reply_to,
 		    "smtp-server=s" => \$smtp_server,
+		    "smtp-server-options=s" => \$smtp_server_options,
 		    "smtp-server-port=s" => \$smtp_server_port,
 		    "smtp-user=s" => \$smtp_authuser,
 		    "smtp-pass:s" => \$smtp_authpass,
@@ -1015,6 +1019,9 @@ X-Mailer: git-send-email $gitversion
 		}
 	}
 
+	unshift (@sendmail_parameters, $smtp_server_options)
+	    if (defined $smtp_server_options);
+
 	if ($dry_run) {
 		# We don't want to send the email.
 	} elsif ($smtp_server =~ m#^/#) {
-- 
1.7.2.2.277.gb49c4

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

* Re: [PATCH 2/2] New send-email option smtpserveroptions.
  2010-09-04 16:06 ` [PATCH 2/2] New send-email option smtpserveroptions Pascal Obry
@ 2010-09-04 16:21   ` Junio C Hamano
  2010-09-04 16:39     ` Pascal Obry
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2010-09-04 16:21 UTC (permalink / raw)
  To: Pascal Obry; +Cc: git

Pascal Obry <pascal@obry.net> writes:

> diff --git a/git-send-email.perl b/git-send-email.perl
> index 0063606..e5cdda7 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -60,6 +60,7 @@ git send-email [options] <file | directory | rev-list options >
>      --envelope-sender       <str>  * Email envelope sender.
>      --smtp-server       <str:int>  * Outgoing SMTP server to use. The port
>                                       is optional. Default 'localhost'.
> +    --smtp-server-options   <int>  * Outgoing SMTP server options to use.

Is it really an int?

> @@ -279,6 +282,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
> ...
> +		    "smtp-server-options=s" => \$smtp_server_options,
> @@ -1015,6 +1019,9 @@ X-Mailer: git-send-email $gitversion
>  		}
>  	}
>  
> +	unshift (@sendmail_parameters, $smtp_server_options)
> +	    if (defined $smtp_server_options);
> +

I suspect this would not work, unless you are aiming to add just a
singular $smtp_server_option, as the actual program invocation looks like
this later in the program:

	} elsif ($smtp_server =~ m#^/#) {
		my $pid = open my $sm, '|-';
		defined $pid or die $!;
		if (!$pid) {
			exec($smtp_server, @sendmail_parameters) or die $!;
		}
		print $sm "$header\n$message";

Somebody in the code before this unshift needs to split the single string
in $smtp_server_options into multiple parameters, or better yet, it needs
to accept more than one --smtp-server-option=foo --smtp-server-option=bar
and accumulate them in @smtp_server_options.

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

* Re: [PATCH 2/2] New send-email option smtpserveroptions.
  2010-09-04 16:21   ` Junio C Hamano
@ 2010-09-04 16:39     ` Pascal Obry
  2010-09-04 17:57       ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 6+ messages in thread
From: Pascal Obry @ 2010-09-04 16:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio,

>> +    --smtp-server-options   <int>  * Outgoing SMTP server options to use.
> 
> Is it really an int?

Oups! Fixed.

>> +	unshift (@sendmail_parameters, $smtp_server_options)
>> +	    if (defined $smtp_server_options);
>> +
> 
> I suspect this would not work, unless you are aiming to add just a
> singular $smtp_server_option, as the actual program invocation looks like
> this later in the program:
> 
> 	} elsif ($smtp_server =~ m#^/#) {
> 		my $pid = open my $sm, '|-';
> 		defined $pid or die $!;
> 		if (!$pid) {
> 			exec($smtp_server, @sendmail_parameters) or die $!;
> 		}
> 		print $sm "$header\n$message";
> 
> Somebody in the code before this unshift needs to split the single string
> in $smtp_server_options into multiple parameters, or better yet, it needs
> to accept more than one --smtp-server-option=foo --smtp-server-option=bar
> and accumulate them in @smtp_server_options.

For sure this is above my expertise in Perl. As I said I have never
worked with Perl. If someone gives me some pointers I can give it a try
otherwise I surrender :)

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B

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

* Re: [PATCH 2/2] New send-email option smtpserveroptions.
  2010-09-04 16:39     ` Pascal Obry
@ 2010-09-04 17:57       ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 6+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-09-04 17:57 UTC (permalink / raw)
  To: pascal; +Cc: Junio C Hamano, git

On Sat, Sep 4, 2010 at 16:39, Pascal Obry <pascal.obry@gmail.com> wrote:

> For sure this is above my expertise in Perl. As I said I have never
> worked with Perl. If someone gives me some pointers I can give it a try
> otherwise I surrender :)

The best option, as Junio points out is to accumulate options with
--smtp-server-option=. The alternative is to to to parse shell
syntax. E.g. --options='--foo="bar blah" --foo=..' means you can't
split on \s+.

See the \@to option in GetOptions for how to do that.

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

end of thread, other threads:[~2010-09-04 17:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-04 16:06 [PATCH 0/2] Add support for SMTP server options Pascal Obry
2010-09-04 16:06 ` [PATCH 1/2] Minor indentation fix Pascal Obry
2010-09-04 16:06 ` [PATCH 2/2] New send-email option smtpserveroptions Pascal Obry
2010-09-04 16:21   ` Junio C Hamano
2010-09-04 16:39     ` Pascal Obry
2010-09-04 17:57       ` Ævar Arnfjörð Bjarmason

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).