{"thread":{"id":"24972","subject":"[PATCH 0/2] Add support for SMTP server options","startedAt":"2010-09-04T16:06:10Z","lastAt":"2010-09-04T17:57:32Z","messageCount":6,"participants":["Pascal Obry","Junio C Hamano","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"149847","messageId":"1283616372-3340-1-git-send-email-pascal@obry.net","threadId":"24972","inReplyTo":null,"subject":"[PATCH 0/2] Add support for SMTP server options","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2010-09-04T16:06:10Z","receivedAt":"2010-09-04T16:06:10Z","isPatch":true,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"I'm not familiar at all with Perl so comments on style or usage most\nwelcomed. This patch is to introduce a way to pass specific options to the\nSMTP server used by git-send-email.\n\nI need that to be able to use different SMTP account (wanadoo, gmail...) on\nsome Git repositories to send over proper identity.\n\nPascal Obry (2):\n  Minor indentation fix.\n  New send-email option smtpserveroptions.\n\n Documentation/git-send-email.txt |    5 +++++\n git-send-email.perl              |   11 +++++++++--\n 2 files changed, 14 insertions(+), 2 deletions(-)\n\n-- \n1.7.2.2.277.gb49c4\n"},{"id":"149848","messageId":"1283616372-3340-2-git-send-email-pascal@obry.net","threadId":"24972","inReplyTo":"1283616372-3340-1-git-send-email-pascal@obry.net","subject":"[PATCH 1/2] Minor indentation fix.","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2010-09-04T16:06:11Z","receivedAt":"2010-09-04T16:06:11Z","isPatch":true,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"---\n git-send-email.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 6dab3bf..0063606 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -212,7 +212,7 @@ my %config_settings = (\n     \"smtpserverport\" => \\$smtp_server_port,\n     \"smtpuser\" => \\$smtp_authuser,\n     \"smtppass\" => \\$smtp_authpass,\n-\t\"smtpdomain\" => \\$smtp_domain,\n+    \"smtpdomain\" => \\$smtp_domain,\n     \"to\" => \\@to,\n     \"cc\" => \\@initial_cc,\n     \"cccmd\" => \\$cc_cmd,\n-- \n1.7.2.2.277.gb49c4\n"},{"id":"149849","messageId":"1283616372-3340-3-git-send-email-pascal@obry.net","threadId":"24972","inReplyTo":"1283616372-3340-1-git-send-email-pascal@obry.net","subject":"[PATCH 2/2] New send-email option smtpserveroptions.","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2010-09-04T16:06:12Z","receivedAt":"2010-09-04T16:06:12Z","isPatch":true,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"The new command line parameter --smtp-server-options or default\nconfiguration sendemail.smtpserveroptions can be used to pass\nspecific options to the SMTP server.\n---\n Documentation/git-send-email.txt |    5 +++++\n git-send-email.perl              |    9 ++++++++-\n 2 files changed, 13 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex c283084..425b102 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -157,6 +157,11 @@ user is prompted for a password while the input is masked for privacy.\n \t`/usr/lib/sendmail` if such program is available, or\n \t`localhost` otherwise.\n \n+--smtp-server-options=<options>::\n+\tIf set, specifies the outgoing SMTP server options to use.\n+\tDefault value can be specified by the 'sendemail.smtpserveroptions'\n+\tconfiguration option.\n+\n --smtp-server-port=<port>::\n \tSpecifies a port different from the default port (SMTP\n \tservers typically listen to smtp port 25, but may also listen to\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 0063606..e5cdda7 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -60,6 +60,7 @@ git send-email [options] <file | directory | rev-list options >\n     --envelope-sender       <str>  * Email envelope sender.\n     --smtp-server       <str:int>  * Outgoing SMTP server to use. The port\n                                      is optional. Default 'localhost'.\n+    --smtp-server-options   <int>  * Outgoing SMTP server options to use.\n     --smtp-server-port      <int>  * Outgoing SMTP server port.\n     --smtp-user             <str>  * Username for SMTP-AUTH.\n     --smtp-pass             <str>  * Password for SMTP-AUTH; not necessary.\n@@ -188,7 +189,8 @@ sub do_edit {\n \n # Variables with corresponding config settings\n my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);\n-my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);\n+my ($smtp_server, $smtp_server_port, $smtp_server_options);\n+my ($smtp_authuser, $smtp_encryption);\n my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain);\n my ($validate, $confirm);\n my (@suppress_cc);\n@@ -210,6 +212,7 @@ my %config_bool_settings = (\n my %config_settings = (\n     \"smtpserver\" => \\$smtp_server,\n     \"smtpserverport\" => \\$smtp_server_port,\n+    \"smtpserveroptions\" => \\$smtp_server_options,\n     \"smtpuser\" => \\$smtp_authuser,\n     \"smtppass\" => \\$smtp_authpass,\n     \"smtpdomain\" => \\$smtp_domain,\n@@ -279,6 +282,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"no-bcc\" => \\$no_bcc,\n \t\t    \"chain-reply-to!\" => \\$chain_reply_to,\n \t\t    \"smtp-server=s\" => \\$smtp_server,\n+\t\t    \"smtp-server-options=s\" => \\$smtp_server_options,\n \t\t    \"smtp-server-port=s\" => \\$smtp_server_port,\n \t\t    \"smtp-user=s\" => \\$smtp_authuser,\n \t\t    \"smtp-pass:s\" => \\$smtp_authpass,\n@@ -1015,6 +1019,9 @@ X-Mailer: git-send-email $gitversion\n \t\t}\n \t}\n \n+\tunshift (@sendmail_parameters, $smtp_server_options)\n+\t    if (defined $smtp_server_options);\n+\n \tif ($dry_run) {\n \t\t# We don't want to send the email.\n \t} elsif ($smtp_server =~ m#^/#) {\n-- \n1.7.2.2.277.gb49c4\n"},{"id":"149851","messageId":"7v4oe5xyxd.fsf@alter.siamese.dyndns.org","threadId":"24972","inReplyTo":"1283616372-3340-3-git-send-email-pascal@obry.net","subject":"Re: [PATCH 2/2] New send-email option smtpserveroptions.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-04T16:21:02Z","receivedAt":"2010-09-04T16:21:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pascal Obry <pascal@obry.net> writes:\n\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 0063606..e5cdda7 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -60,6 +60,7 @@ git send-email [options] <file | directory | rev-list options >\n>      --envelope-sender       <str>  * Email envelope sender.\n>      --smtp-server       <str:int>  * Outgoing SMTP server to use. The port\n>                                       is optional. Default 'localhost'.\n> +    --smtp-server-options   <int>  * Outgoing SMTP server options to use.\n\nIs it really an int?\n\n> @@ -279,6 +282,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n> ...\n> +\t\t    \"smtp-server-options=s\" => \\$smtp_server_options,\n> @@ -1015,6 +1019,9 @@ X-Mailer: git-send-email $gitversion\n>  \t\t}\n>  \t}\n>  \n> +\tunshift (@sendmail_parameters, $smtp_server_options)\n> +\t    if (defined $smtp_server_options);\n> +\n\nI suspect this would not work, unless you are aiming to add just a\nsingular $smtp_server_option, as the actual program invocation looks like\nthis later in the program:\n\n\t} elsif ($smtp_server =~ m#^/#) {\n\t\tmy $pid = open my $sm, '|-';\n\t\tdefined $pid or die $!;\n\t\tif (!$pid) {\n\t\t\texec($smtp_server, @sendmail_parameters) or die $!;\n\t\t}\n\t\tprint $sm \"$header\\n$message\";\n\nSomebody in the code before this unshift needs to split the single string\nin $smtp_server_options into multiple parameters, or better yet, it needs\nto accept more than one --smtp-server-option=foo --smtp-server-option=bar\nand accumulate them in @smtp_server_options.\n"},{"id":"149853","messageId":"4C827657.3000508@obry.net","threadId":"24972","inReplyTo":"7v4oe5xyxd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] New send-email option smtpserveroptions.","fromName":"Pascal Obry","fromEmail":"pascal.obry@gmail.com","sentAt":"2010-09-04T16:39:51Z","receivedAt":"2010-09-04T16:39:51Z","isPatch":true,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"Junio,\n\n>> +    --smtp-server-options   <int>  * Outgoing SMTP server options to use.\n> \n> Is it really an int?\n\nOups! Fixed.\n\n>> +\tunshift (@sendmail_parameters, $smtp_server_options)\n>> +\t    if (defined $smtp_server_options);\n>> +\n> \n> I suspect this would not work, unless you are aiming to add just a\n> singular $smtp_server_option, as the actual program invocation looks like\n> this later in the program:\n> \n> \t} elsif ($smtp_server =~ m#^/#) {\n> \t\tmy $pid = open my $sm, '|-';\n> \t\tdefined $pid or die $!;\n> \t\tif (!$pid) {\n> \t\t\texec($smtp_server, @sendmail_parameters) or die $!;\n> \t\t}\n> \t\tprint $sm \"$header\\n$message\";\n> \n> Somebody in the code before this unshift needs to split the single string\n> in $smtp_server_options into multiple parameters, or better yet, it needs\n> to accept more than one --smtp-server-option=foo --smtp-server-option=bar\n> and accumulate them in @smtp_server_options.\n\nFor sure this is above my expertise in Perl. As I said I have never\nworked with Perl. If someone gives me some pointers I can give it a try\notherwise I surrender :)\n\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|    http://www.obry.net  -  http://v2p.fr.eu.org\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B\n"},{"id":"149857","messageId":"AANLkTinnoBUp139iXxA=p1Q3bMJStk=a+FiZbzN9q6rv@mail.gmail.com","threadId":"24972","inReplyTo":"4C827657.3000508@obry.net","subject":"Re: [PATCH 2/2] New send-email option smtpserveroptions.","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-09-04T17:57:32Z","receivedAt":"2010-09-04T17:57:32Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Sat, Sep 4, 2010 at 16:39, Pascal Obry <pascal.obry@gmail.com> wrote:\n\n> For sure this is above my expertise in Perl. As I said I have never\n> worked with Perl. If someone gives me some pointers I can give it a try\n> otherwise I surrender :)\n\nThe best option, as Junio points out is to accumulate options with\n--smtp-server-option=. The alternative is to to to parse shell\nsyntax. E.g. --options='--foo=\"bar blah\" --foo=..' means you can't\nsplit on \\s+.\n\nSee the \\@to option in GetOptions for how to do that.\n"}]}