Add support for SMTP server options
v4 cover Add support for SMTP server options
This is v4 of the patch thanks to Junio and AEvar for the review and help.
context:
--------
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.
change since v3:
----------------
I have moved smtp server option description after smtp server port. Seems more natural to me.
I have added note about the fact that multiple lines are needed for each option in configuration files.
patches:
--------
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/config.txt | 1 + Documentation/git-send-email.txt | 9 +++++++++ git-send-email.perl | 12 +++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.2.2.277.gb49c4
PATCH v4 1/3 Minor indentation fix.
--- git-send-email.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git-send-email.perl +1 -1
@@ -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,
Signature · 1 line
1.7.3.rc0
PATCH v4 2/3 Remove @smtp_host_parts variable as not used.
In reply to Pascal Obry--- git-send-email.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git-send-email.perl +1 -1
@@ -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);
Signature · 1 line
1.7.3.rc0
PATCH v4 3/3 New send-email option smtpserveroption.
In reply to Pascal ObryThe 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/config.txt | 1 + Documentation/git-send-email.txt | 9 +++++++++ git-send-email.perl | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletions(-)
Documentation/config.txt +1 -0
@@ -1716,6 +1716,7 @@ sendemail.to:: sendemail.smtpdomain:: sendemail.smtpserver:: sendemail.smtpserverport:: +sendemail.smtpserveroption:: sendemail.smtpuser:: sendemail.thread:: sendemail.validate::
Documentation/git-send-email.txt +9 -0
@@ -165,6 +165,15 @@ user is prompted for a password while the input is masked for privacy. are also accepted. The port can also be set with the 'sendemail.smtpserverport' configuration variable. +--smtp-server-option=<option>:: + 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. Likewise, different lines in the configuration files +must be used for each option. + --smtp-ssl:: Legacy alias for '--smtp-encryption ssl'.
git-send-email.perl +7 -1
@@ -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#^/#) {
Signature · 1 line
1.7.3.rc0