# [PATCH v2 0/3] Add support for SMTP server options

7 messages from 2010-09-04 to 2010-09-05. Participants: Pascal Obry, Ævar Arnfjörð Bjarmason.
Thread: https://gitlist.dev/t/24974

## Pascal Obry, 2010-09-04 19:55

Subject: [PATCH v2 0/3] Add support for SMTP server options
Message-ID: <1283630128-3472-1-git-send-email-pascal@obry.net>
URL: https://gitlist.dev/e/1283630128-3472-1-git-send-email-pascal%40obry.net

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

This is v2 of the patch thanks to Junio and AEvar for the initial review
and help.

The two first patches are really code clean-up found while working on this
new feature. The last patch is the actual implementation of this new
feature.

Pascal Obry (3):
  Minor indentation fix.
  Remove @smtp_host_parts variable as not used.
  New send-email option smtpserveroption.

 Documentation/git-send-email.txt |    8 ++++++++
 git-send-email.perl              |   12 +++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

-- 
1.7.2.2.277.gb49c4

```

## Pascal Obry, 2010-09-04 19:55

Subject: [PATCH v2 1/3] Minor indentation fix.
Message-ID: <1283630128-3472-2-git-send-email-pascal@obry.net>
URL: https://gitlist.dev/e/1283630128-3472-2-git-send-email-pascal%40obry.net
In-Reply-To: <1283630128-3472-1-git-send-email-pascal@obry.net>

```
---
 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

```

## Pascal Obry, 2010-09-04 19:55

Subject: [PATCH v2 2/3] Remove @smtp_host_parts variable as not used.
Message-ID: <1283630128-3472-3-git-send-email-pascal@obry.net>
URL: https://gitlist.dev/e/1283630128-3472-3-git-send-email-pascal%40obry.net
In-Reply-To: <1283630128-3472-1-git-send-email-pascal@obry.net>

```
---
 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 0063606..39cb5af 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -189,7 +189,7 @@ 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 ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain);
+my ($identity, $aliasfiletype, @alias_files, $smtp_domain);
 my ($validate, $confirm);
 my (@suppress_cc);
 my ($auto_8bit_encoding);
-- 
1.7.2.2.277.gb49c4

```

## Pascal Obry, 2010-09-04 19:55

Subject: [PATCH v2 3/3] New send-email option smtpserveroption.
Message-ID: <1283630128-3472-4-git-send-email-pascal@obry.net>
URL: https://gitlist.dev/e/1283630128-3472-4-git-send-email-pascal%40obry.net
In-Reply-To: <1283630128-3472-1-git-send-email-pascal@obry.net>

```
The new command line parameter --smtp-server-option or default
configuration sendemail.smtpserveroption can be used to pass
specific options to the SMTP server. Update the documentation
accordingly.
---
 Documentation/git-send-email.txt |    8 ++++++++
 git-send-email.perl              |    8 +++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index c283084..ed30be8 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -157,6 +157,14 @@ 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-option=<options>::
+	If set, specifies the outgoing SMTP server option to use.
+	Default value can be specified by the 'sendemail.smtpserveroption'
+	configuration option.
++
+The --smtp-server-option option must be repeated for each option you want
+to pass to the server.
+
 --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 39cb5af..47989fe 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-option    <str>  * Outgoing SMTP server option 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_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,
+    "smtpserveroption" => \@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-option=s" => \@smtp_server_options,
 		    "smtp-server-port=s" => \$smtp_server_port,
 		    "smtp-user=s" => \$smtp_authuser,
 		    "smtp-pass:s" => \$smtp_authpass,
@@ -1015,6 +1019,8 @@ X-Mailer: git-send-email $gitversion
 		}
 	}
 
+	unshift (@sendmail_parameters, @smtp_server_options);
+
 	if ($dry_run) {
 		# We don't want to send the email.
 	} elsif ($smtp_server =~ m#^/#) {
-- 
1.7.2.2.277.gb49c4

```

## Pascal Obry, 2010-09-04 20:09

Subject: Re: [PATCH v2 3/3] New send-email option smtpserveroption.
Message-ID: <4C82A78C.6090602@obry.net>
URL: https://gitlist.dev/e/4C82A78C.6090602%40obry.net
In-Reply-To: <1283630128-3472-4-git-send-email-pascal@obry.net>

```
Le 04/09/2010 21:55, Pascal Obry a écrit :
> +--smtp-server-option=<options>::

should be:               ^
                         option

Will issue another patch set (waiting for feedback on v2).

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

```

## Ævar Arnfjörð Bjarmason, 2010-09-04 20:35

Subject: Re: [PATCH v2 3/3] New send-email option smtpserveroption.
Message-ID: <AANLkTinvos_65kb2uO9bTpRAaCeN+N63-KsMmARadt=3@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinvos_65kb2uO9bTpRAaCeN%2BN63-KsMmARadt%3D3%40mail.gmail.com
In-Reply-To: <1283630128-3472-4-git-send-email-pascal@obry.net>

```
On Sat, Sep 4, 2010 at 19:55, Pascal Obry <pascal@obry.net> wrote:

Looks good, but tests are always nice :)

> +       unshift (@sendmail_parameters, @smtp_server_options);
> +

It just seems iffy to not be able to provide options without having
the sendmail_parameters. Or maybe all usecases for this involve a
program that takes sendmail-like arguments, so this isn't an issue.

```

## Pascal Obry, 2010-09-05 07:15

Subject: Re: [PATCH v2 3/3] New send-email option smtpserveroption.
Message-ID: <4C83438B.4010701@obry.net>
URL: https://gitlist.dev/e/4C83438B.4010701%40obry.net
In-Reply-To: <AANLkTinvos_65kb2uO9bTpRAaCeN+N63-KsMmARadt=3@mail.gmail.com>

```
Ævar,

>> +       unshift (@sendmail_parameters, @smtp_server_options);
>> +
> 
> It just seems iffy to not be able to provide options without having
> the sendmail_parameters. Or maybe all usecases for this involve a
> program that takes sendmail-like arguments, so this isn't an issue.

As far as I understand sendmail_parameters is always used and set:

	my @sendmail_parameters = ('-i', @recipients);

This is even documented:

--smtp-server=<host>::
	If set, specifies the outgoing SMTP server to use (e.g.
	`smtp.example.com` or a raw IP address).  Alternatively it can
	specify a full pathname of a sendmail-like program instead;
	the program must support the `-i` option.  Default value can
	be specified by the 'sendemail.smtpserver' configuration
	option; the built-in default is `/usr/sbin/sendmail` or
	`/usr/lib/sendmail` if such program is available, or
	`localhost` otherwise.

-- 

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

```
