{"thread":{"id":"9740","subject":"[PATCH] send-email: Add support for SSL and SMTP-AUTH","startedAt":"2007-09-02T03:14:45Z","lastAt":"2007-09-02T12:32:29Z","messageCount":5,"participants":["Douglas Stockwell","Junio C Hamano","Wincent Colaiuta","David Symonds","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"52165","messageId":"11887028854022-git-send-email-doug@11011.net","threadId":"9740","inReplyTo":null,"subject":"[PATCH] send-email: Add support for SSL and SMTP-AUTH","fromName":"Douglas Stockwell","fromEmail":"douglas.stockwell@gmail.com","sentAt":"2007-09-02T03:14:45Z","receivedAt":"2007-09-02T03:14:45Z","isPatch":true,"sender":{"key":"douglas.stockwell@gmail.com","avatar":null},"body":"Allows username and password to be given using --smtp-authuser\nand --smtp-authpass. SSL use is flagged by --smtp-ssl. These are\nbacked by corresponding defaults in the git configuration file.\n\nSigned-off-by: Douglas Stockwell <doug@11011.net>\n---\n Documentation/git-send-email.txt |   21 +++++++++++++++-\n git-send-email.perl              |   50 ++++++++++++++++++++++++++++++-------\n 2 files changed, 60 insertions(+), 11 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 8231286..471c268 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -79,6 +79,16 @@ The --cc option must be repeated for each user you want on the cc list.\n \t`/usr/lib/sendmail` if such program is available, or\n \t`localhost` otherwise.\n \n+--smtp-authuser, --smtp-authpass::\n+\tUsername and password for SMTP-AUTH. Defaults are the values of\n+\tthe configuration values 'sendemail.smtpauthuser' and\n+\t'sendemail.smtpauthpass'. If not set, authentication is not attempted.\n+\n+--smtp-ssl::\n+\tIf set, connects to the SMTP server using SSL.\n+\tDefault is the value of the 'sendemail.smtpssl' configuration value;\n+\tif that is unspecified, does not use SSL.\n+\n --subject::\n \tSpecify the initial subject of the email thread.\n \tOnly necessary if --compose is also set.  If --compose\n@@ -132,7 +142,16 @@ sendemail.chainreplyto::\n \tparameter.\n \n sendemail.smtpserver::\n-\tDefault smtp server to use.\n+\tDefault SMTP server to use.\n+\n+sendemail.smtpauthuser::\n+\tDefault SMTP-AUTH username.\n+\n+sendemail.smtpauthpass::\n+\tDefault SMTP-AUTH password.\n+\n+sendemail.smtpssl::\n+\tBoolean value specifying the default to the '--smtp-ssl' parameter.\n \n Author\n ------\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex f1a8855..38e8395 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -73,6 +73,12 @@ Options:\n    --smtp-server  If set, specifies the outgoing SMTP server to use.\n                   Defaults to localhost.\n \n+   --smtp-authuser The username for SMTP-AUTH.\n+\n+   --smtp-authpass The password for SMTP-AUTH.\n+\n+   --smtp-ssl     If set, connects to the SMTP server using SSL.\n+\n    --suppress-from Suppress sending emails to yourself if your address\n                   appears in a From: line. Defaults to off.\n \n@@ -142,7 +148,6 @@ my $compose_filename = \".msg.$$\";\n my (@to,@cc,@initial_cc,@bcclist,@xh,\n \t$initial_reply_to,$initial_subject,@files,$author,$sender,$compose,$time);\n \n-my $smtp_server;\n my $envelope_sender;\n \n # Example reply to:\n@@ -161,17 +166,34 @@ my ($quiet, $dry_run) = (0, 0);\n \n # Variables with corresponding config settings\n my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc);\n+my ($smtp_server, $smtp_authuser, $smtp_authpass, $smtp_ssl);\n \n-my %config_settings = (\n+my %config_bool_settings = (\n     \"thread\" => [\\$thread, 1],\n     \"chainreplyto\" => [\\$chain_reply_to, 1],\n     \"suppressfrom\" => [\\$suppress_from, 0],\n     \"signedoffcc\" => [\\$signed_off_cc, 1],\n+    \"smtpssl\" => [\\$smtp_ssl, 0]\n+);\n+\n+my %config_string_settings = (\n+    \"smtpserver\" => [\\$smtp_server, undef],\n+    \"smtpauthuser\" => [\\$smtp_authuser, undef],\n+    \"smtpauthpass\" => [\\$smtp_authpass, undef],\n );\n \n-foreach my $setting (keys %config_settings) {\n+foreach my $setting (keys %config_bool_settings) {\n     my $config = $repo->config_bool(\"sendemail.$setting\");\n-    ${$config_settings{$setting}->[0]} = (defined $config) ? $config : $config_settings{$setting}->[1];\n+    ${$config_bool_settings{$setting}->[0]} = (defined $config)\n+        ? $config\n+        : $config_bool_settings{$setting}->[1];\n+}\n+\n+foreach my $setting (keys %config_string_settings) {\n+    my $config = $repo->config(\"sendemail.$setting\");\n+    ${$config_string_settings{$setting}->[0]} = (defined $config)\n+        ? $config\n+        : $config_string_settings{$setting}->[1];\n }\n \n @bcclist = $repo->config('sendemail.bcc');\n@@ -190,6 +212,9 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"bcc=s\" => \\@bcclist,\n \t\t    \"chain-reply-to!\" => \\$chain_reply_to,\n \t\t    \"smtp-server=s\" => \\$smtp_server,\n+\t\t    \"smtp-authuser=s\" => \\$smtp_authuser,\n+\t\t    \"smtp-authpass=s\" => \\$smtp_authpass,\n+\t\t    \"smtp-ssl!\" => \\$smtp_ssl,\n \t\t    \"compose\" => \\$compose,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"suppress-from!\" => \\$suppress_from,\n@@ -315,10 +340,7 @@ if ($thread && !defined $initial_reply_to && $prompting) {\n \t$initial_reply_to =~ s/(^\\s+|\\s+$)//g;\n }\n \n-if (!$smtp_server) {\n-\t$smtp_server = $repo->config('sendemail.smtpserver');\n-}\n-if (!$smtp_server) {\n+if (!defined $smtp_server) {\n \tforeach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {\n \t\tif (-x $_) {\n \t\t\t$smtp_server = $_;\n@@ -548,8 +570,16 @@ X-Mailer: git-send-email $gitversion\n \t\tprint $sm \"$header\\n$message\";\n \t\tclose $sm or die $?;\n \t} else {\n-\t\trequire Net::SMTP;\n-\t\t$smtp ||= Net::SMTP->new( $smtp_server );\n+\t\tif ($smtp_ssl) {\n+\t\t\trequire Net::SMTP::SSL;\n+\t\t\t$smtp ||= Net::SMTP::SSL->new( $smtp_server, Port => 465 );\n+\t\t}\n+\t\telse {\n+\t\t\trequire Net::SMTP;\n+\t\t\t$smtp ||= Net::SMTP->new( $smtp_server );\n+\t\t}\n+\t\t$smtp->auth( $smtp_authuser, $smtp_authpass )\n+\t\t\tor die $smtp->message if (defined $smtp_authuser);\n \t\t$smtp->mail( $raw_from ) or die $smtp->message;\n \t\t$smtp->to( @recipients ) or die $smtp->message;\n \t\t$smtp->data or die $smtp->message;\n-- \n1.5.3.rc7.17.gd77cc\n"},{"id":"52174","messageId":"7vveatpklg.fsf@gitster.siamese.dyndns.org","threadId":"9740","inReplyTo":"11887028854022-git-send-email-doug@11011.net","subject":"Re: [PATCH] send-email: Add support for SSL and SMTP-AUTH","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-02T07:55:39Z","receivedAt":"2007-09-02T07:55:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks for the patch.  I think SMTP-AUTH is a worthy addition.\n\nI however have a bit of reservation about making the password\nitself a configuration variable.  I understand this is good\nenough for the simplest case that you have only single e-mail\nidentity and mailserver to talk to.\n\nBy defining the two \"default\" variables, you are encouraging\nusers who want to use different identity per project to define\nthe smtpauthuser and smtpauthpass variables in .git/config of\neach repository.  I see two issues with this.\n\n (1) Suppose I interact with under one mail identity with\n     projects A and B and under another mail identity with\n     project C and D.  I need to have duplicate variable\n     settings in .git/config of A and B for one and another\n     duplicated sets in C and D.\n\n (2) Although the recommended BCP is not to allow other people\n     to interact with your private working repository (iow, you\n     keep a separate \"bare\" repository you use solely for\n     publishing, you push from your private working repository\n     to that publishing repository, and have others look at only\n     the publishing repository), people often do not follow this\n     BCP and expose their private working repository to their\n     colleages for fetching (or even pushing).  We currently do\n     not allow reading remote repository's configuration over\n     the git protocol, but there were some cases in the past\n     that the ability to do so might lead to their solutions\n     discussed on the list.  We might not keep .git/config in\n     the repository that is accessed by fetch clients private in\n     the future.\n\nSo it might be better to split the configuration variables in this\nway:\n\n (1) in ~/.gitconfig (that is hopefully readable only by the\n     user):\n\n\t[sendemail \"default\"]\n        \tserver = mail.isp.com\n                user = junkio\n                pass = junkio-password-for-mail-isp-com\n\n\t[sendemail \"git\"]\n        \tserver = mail.git.xz\n                user = gitster\n                pass = gitster-password-for-mail-git.xz\n\n     This defines two \"mail identities\" I could use, depending\n     on which project's repository I run send-email.\n\n (2) in project/.git/config:\n\n\t[sendemail]\n        \tidentity = git\n\n     This defines which \"mail identity\" I want to use for this\n     particular project.\n\nThis way, you can maintain more than one identity by having\nmultiple [sendemail \"$identity\"] sections in ~/.gitconfig, and\navoid having to expose and duplicate user/pass in various\nproject's .git/config.\n\nThe look-up rules by send-email program would be:\n\n * if anything is given explicitly from the command line, use\n   that; otherwise\n\n * if sendemail.identity does not exist, pretend\n   \"sendemail.identity = default\" was given (let's call that\n   identity nickname $identity in the following);\n\n   * if sendemail.$identity.server.exists, use that as the smtp\n     server to contact; otherwise sendemail.smtpserver is used;\n\n   * for user/pass information, use sendemail.$identity.user and\n     sendemail.$identity.pass.\n\nHmm?\n"},{"id":"52181","messageId":"3533A53F-9120-4151-A9E7-C23CB1C84E1B@wincent.com","threadId":"9740","inReplyTo":"7vveatpklg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] send-email: Add support for SSL and SMTP-AUTH","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-09-02T09:43:56Z","receivedAt":"2007-09-02T09:43:56Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 2/9/2007, a las 9:55, Junio C Hamano escribió:\n\n> So it might be better to split the configuration variables in this\n> way:\n>\n>  (1) in ~/.gitconfig (that is hopefully readable only by the\n>      user):\n>\n> \t[sendemail \"default\"]\n>         \tserver = mail.isp.com\n>                 user = junkio\n>                 pass = junkio-password-for-mail-isp-com\n>\n> \t[sendemail \"git\"]\n>         \tserver = mail.git.xz\n>                 user = gitster\n>                 pass = gitster-password-for-mail-git.xz\n>\n>      This defines two \"mail identities\" I could use, depending\n>      on which project's repository I run send-email.\n>\n>  (2) in project/.git/config:\n>\n> \t[sendemail]\n>         \tidentity = git\n>\n>      This defines which \"mail identity\" I want to use for this\n>      particular project.\n>\n> This way, you can maintain more than one identity by having\n> multiple [sendemail \"$identity\"] sections in ~/.gitconfig, and\n> avoid having to expose and duplicate user/pass in various\n> project's .git/config.\n\nSounds like a good plan.\n\nWincent\n"},{"id":"52187","messageId":"ee77f5c20709020406p491ef90eoc2c6096db6e6e04e@mail.gmail.com","threadId":"9740","inReplyTo":"7vveatpklg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] send-email: Add support for SSL and SMTP-AUTH","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-09-02T11:06:17Z","receivedAt":"2007-09-02T11:06:17Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"On 02/09/07, Junio C Hamano <gitster@pobox.com> wrote:\n\n> So it might be better to split the configuration variables in this\n> way:\n>\n>  (1) in ~/.gitconfig (that is hopefully readable only by the\n>      user):\n\nPerhaps git should then start warning if ~/.gitconfig is world (and\nprobably group) readable/writeable, a la ssh's ~/.ssh/X (for various\nvalues of X)?\n\n\nDave.\n"},{"id":"52192","messageId":"Pine.LNX.4.64.0709021331570.28586@racer.site","threadId":"9740","inReplyTo":"7vveatpklg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] send-email: Add support for SSL and SMTP-AUTH","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-02T12:32:29Z","receivedAt":"2007-09-02T12:32:29Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 2 Sep 2007, Junio C Hamano wrote:\n\n> Thanks for the patch.  I think SMTP-AUTH is a worthy addition.\n> \n> I however have a bit of reservation about making the password\n> itself a configuration variable.\n\nWhy not have the password in $HOME/.netrc, and ask interactively if none \nwas found?\n\nCiao,\nDscho\n"}]}