{"thread":{"id":"45950","subject":"[PATCH v4] send-email: --batch-size to work around some SMTP server limit","startedAt":"2017-05-13T01:58:07Z","lastAt":"2017-05-17T00:04:46Z","messageCount":8,"participants":["xiaoqiang zhao","Junio C Hamano","Jan Viktorin","赵小强","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":4,"patchTotal":null},"messages":[{"id":"319588","messageId":"20170513015726.20281-1-zxq_yx_007@163.com","threadId":"45950","inReplyTo":null,"subject":"[PATCH v4] send-email: --batch-size to work around some SMTP server limit","fromName":"xiaoqiang zhao","fromEmail":"zxq_yx_007@163.com","sentAt":"2017-05-13T01:57:26Z","receivedAt":"2017-05-13T01:58:07Z","isPatch":true,"sender":{"key":"zxq_yx_007@163.com","avatar":"https://avatars.githubusercontent.com/u/3981296?v=4"},"body":"Some email servers (e.g. smtp.163.com) limit the number emails to be\nsent per session(connection) and this will lead to a faliure when\nsending many messages.\n\nTeach send-email to disconnect after sending a number of messages\n(configurable via the --batch-size=<num> option), wait for a few\nseconds (configurable via the --relogin-delay=<seconds> option) and\nreconnect, to work around such a limit.\n\nAlso add this two configure option for git config command.\n\nNote:\n   Re-authentication will happen every $<batch-size> messages, so it\nwill be much more acceptable if you use some form of credential helper\n(e.g. the 'sendemail.smtppass' config option), otherwise you will have\nto retype password every time when asked.\n\nSigned-off-by: xiaoqiang zhao <zxq_yx_007@163.com>\n---\n contrib/completion/git-completion.bash |  2 ++\n git-send-email.perl                    | 18 ++++++++++++++++++\n 2 files changed, 20 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex af658995d..29496353a 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2608,6 +2608,8 @@ _git_config ()\n \t\tsendemail.thread\n \t\tsendemail.to\n \t\tsendemail.validate\n+\t\tsendemail.smtpbatchsize\n+\t\tsendemail.smtprelogindelay\n \t\tshowbranch.default\n \t\tstatus.relativePaths\n \t\tstatus.showUntrackedFiles\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex eea0a517f..071d1ab9d 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -81,6 +81,10 @@ git send-email --dump-aliases\n                                      This setting forces to use one of the listed mechanisms.\n     --smtp-debug            <0|1>  * Disable, enable Net::SMTP debug.\n \n+    --batch-size            <int>  * send max <int> message per connection.\n+    --relogin-delay         <int>  * delay <int> seconds between two successive login, default to 1,\n+                                     This option can only be used with --batch-size\n+\n   Automating:\n     --identity              <str>  * Use the sendemail.<id> options.\n     --to-cmd                <str>  * Email To: via `<str> \\$patch_path`\n@@ -153,6 +157,7 @@ my $have_email_valid = eval { require Email::Valid; 1 };\n my $have_mail_address = eval { require Mail::Address; 1 };\n my $smtp;\n my $auth;\n+my $num_sent = 0;\n \n # Regexes for RFC 2047 productions.\n my $re_token = qr/[^][()<>@,;:\\\\\"\\/?.= \\000-\\037\\177-\\377]+/;\n@@ -216,6 +221,7 @@ my ($cover_cc, $cover_to);\n my ($to_cmd, $cc_cmd);\n my ($smtp_server, $smtp_server_port, @smtp_server_options);\n my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);\n+my ($batch_size, $relogin_delay);\n my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);\n my ($validate, $confirm);\n my (@suppress_cc);\n@@ -247,6 +253,8 @@ my %config_settings = (\n     \"smtppass\" => \\$smtp_authpass,\n     \"smtpdomain\" => \\$smtp_domain,\n     \"smtpauth\" => \\$smtp_auth,\n+    \"smtpbatchsize\" => \\$batch_size,\n+    \"smtprelogindelay\" => \\$relogin_delay,\n     \"to\" => \\@initial_to,\n     \"tocmd\" => \\$to_cmd,\n     \"cc\" => \\@initial_cc,\n@@ -358,6 +366,8 @@ $rc = GetOptions(\n \t\t    \"force\" => \\$force,\n \t\t    \"xmailer!\" => \\$use_xmailer,\n \t\t    \"no-xmailer\" => sub {$use_xmailer = 0},\n+\t\t    \"batch-size=i\" => \\$batch_size,\n+\t\t    \"relogin-delay=i\" => \\$relogin_delay,\n \t );\n \n usage() if $help;\n@@ -1664,6 +1674,14 @@ foreach my $t (@files) {\n \t\t}\n \t}\n \t$message_id = undef;\n+\t$num_sent++;\n+\tif ($num_sent == $batch_size) {\n+\t\t$num_sent = 0;\n+\t\t$smtp->quit if defined $smtp;\n+\t\tundef $smtp;\n+\t\tundef $auth;\n+\t\tsleep($relogin_delay);\n+\t}\n }\n \n # Execute a command (e.g. $to_cmd) to get a list of email addresses\n-- \n2.13.0.rc2.49.g12cd49e6e\n\n\n"},{"id":"319752","messageId":"xmqqfug6wz0s.fsf@gitster.mtv.corp.google.com","threadId":"45950","inReplyTo":"20170513015726.20281-1-zxq_yx_007@163.com","subject":"Re: [PATCH v4] send-email: --batch-size to work around some SMTP server limit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-15T03:59:47Z","receivedAt":"2017-05-15T03:59:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"xiaoqiang zhao <zxq_yx_007@163.com> writes:\n\n> Some email servers (e.g. smtp.163.com) limit the number emails to be\n> sent per session(connection) and this will lead to a faliure when\n> sending many messages.\n>\n> Teach send-email to disconnect after sending a number of messages\n> (configurable via the --batch-size=<num> option), wait for a few\n> seconds (configurable via the --relogin-delay=<seconds> option) and\n> reconnect, to work around such a limit.\n>\n> Also add this two configure option for git config command.\n\ns/configure/configuration/; \"for git config command\" is better left\nunsaid (too obvious).\n\n> Note:\n>    Re-authentication will happen every $<batch-size> messages, so it\n> will be much more acceptable if you use some form of credential helper\n> (e.g. the 'sendemail.smtppass' config option), otherwise you will have\n> to retype password every time when asked.\n\nI think this deserves to be in the end-user documentation (i.e. the\npart of your patch that updates Documentation/git-send-email.txt).\n\nOther than that, looking good ;-)\n\nThanks.\n\n> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>\n> ---\n>  contrib/completion/git-completion.bash |  2 ++\n>  git-send-email.perl                    | 18 ++++++++++++++++++\n>  2 files changed, 20 insertions(+)\n\n"},{"id":"319915","messageId":"20170516141014.6e8487df.viktorin@rehivetech.com","threadId":"45950","inReplyTo":"20170513015726.20281-1-zxq_yx_007@163.com","subject":"Re: [PATCH v4] send-email: --batch-size to work around some SMTP server limit","fromName":"Jan Viktorin","fromEmail":"viktorin@rehivetech.com","sentAt":"2017-05-16T12:10:14Z","receivedAt":"2017-05-16T12:11:35Z","isPatch":true,"sender":{"key":"viktorin@rehivetech.com","avatar":null},"body":"Hello,\n\nwith this patch applied to git 2.12, I could see:\n\nUse of uninitialized value $batch_size in numeric eq (==) at /usr/lib/git-core/git-send-email line 1679\n\nwhen --batch-size is NOT used. See below...\n\nOn Sat, 13 May 2017 09:57:26 +0800\nxiaoqiang zhao <zxq_yx_007@163.com> wrote:\n\n> Some email servers (e.g. smtp.163.com) limit the number emails to be\n> sent per session(connection) and this will lead to a faliure when\n> sending many messages.\n> \n> Teach send-email to disconnect after sending a number of messages\n> (configurable via the --batch-size=<num> option), wait for a few\n> seconds (configurable via the --relogin-delay=<seconds> option) and\n> reconnect, to work around such a limit.\n> \n> Also add this two configure option for git config command.\n> \n> Note:\n>    Re-authentication will happen every $<batch-size> messages, so it\n> will be much more acceptable if you use some form of credential helper\n> (e.g. the 'sendemail.smtppass' config option), otherwise you will have\n> to retype password every time when asked.\n> \n> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>\n> ---\n>  contrib/completion/git-completion.bash |  2 ++\n>  git-send-email.perl                    | 18 ++++++++++++++++++\n>  2 files changed, 20 insertions(+)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index af658995d..29496353a 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2608,6 +2608,8 @@ _git_config ()\n>  \t\tsendemail.thread\n>  \t\tsendemail.to\n>  \t\tsendemail.validate\n> +\t\tsendemail.smtpbatchsize\n> +\t\tsendemail.smtprelogindelay\n>  \t\tshowbranch.default\n>  \t\tstatus.relativePaths\n>  \t\tstatus.showUntrackedFiles\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index eea0a517f..071d1ab9d 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -81,6 +81,10 @@ git send-email --dump-aliases\n>                                       This setting forces to use one of the listed mechanisms.\n>      --smtp-debug            <0|1>  * Disable, enable Net::SMTP debug.\n>  \n> +    --batch-size            <int>  * send max <int> message per connection.\n> +    --relogin-delay         <int>  * delay <int> seconds between two successive login, default to 1,\n> +                                     This option can only be used with --batch-size\n> +\n>    Automating:\n>      --identity              <str>  * Use the sendemail.<id> options.\n>      --to-cmd                <str>  * Email To: via `<str> \\$patch_path`\n> @@ -153,6 +157,7 @@ my $have_email_valid = eval { require Email::Valid; 1 };\n>  my $have_mail_address = eval { require Mail::Address; 1 };\n>  my $smtp;\n>  my $auth;\n> +my $num_sent = 0;\n>  \n>  # Regexes for RFC 2047 productions.\n>  my $re_token = qr/[^][()<>@,;:\\\\\"\\/?.= \\000-\\037\\177-\\377]+/;\n> @@ -216,6 +221,7 @@ my ($cover_cc, $cover_to);\n>  my ($to_cmd, $cc_cmd);\n>  my ($smtp_server, $smtp_server_port, @smtp_server_options);\n>  my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);\n> +my ($batch_size, $relogin_delay);\n>  my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);\n>  my ($validate, $confirm);\n>  my (@suppress_cc);\n> @@ -247,6 +253,8 @@ my %config_settings = (\n>      \"smtppass\" => \\$smtp_authpass,\n>      \"smtpdomain\" => \\$smtp_domain,\n>      \"smtpauth\" => \\$smtp_auth,\n> +    \"smtpbatchsize\" => \\$batch_size,\n> +    \"smtprelogindelay\" => \\$relogin_delay,\n>      \"to\" => \\@initial_to,\n>      \"tocmd\" => \\$to_cmd,\n>      \"cc\" => \\@initial_cc,\n> @@ -358,6 +366,8 @@ $rc = GetOptions(\n>  \t\t    \"force\" => \\$force,\n>  \t\t    \"xmailer!\" => \\$use_xmailer,\n>  \t\t    \"no-xmailer\" => sub {$use_xmailer = 0},\n> +\t\t    \"batch-size=i\" => \\$batch_size,\n> +\t\t    \"relogin-delay=i\" => \\$relogin_delay,\n>  \t );\n>  \n>  usage() if $help;\n> @@ -1664,6 +1674,14 @@ foreach my $t (@files) {\n>  \t\t}\n>  \t}\n>  \t$message_id = undef;\n> +\t$num_sent++;\n> +\tif ($num_sent == $batch_size) {\n\nThis is the line. I think, batch_size can be sometimes uninitialized\nwhile this statement is executed.\n\nRegards\nJan\n\n> +\t\t$num_sent = 0;\n> +\t\t$smtp->quit if defined $smtp;\n> +\t\tundef $smtp;\n> +\t\tundef $auth;\n> +\t\tsleep($relogin_delay);\n> +\t}\n>  }\n>  \n>  # Execute a command (e.g. $to_cmd) to get a list of email addresses\n"},{"id":"319920","messageId":"2BB8B551-01A6-4470-9370-5B1A03EB96D0@163.com","threadId":"45950","inReplyTo":"20170516141014.6e8487df.viktorin@rehivetech.com","subject":"Re: [PATCH v4] send-email: --batch-size to work around some SMTP server limit","fromName":"赵小强","fromEmail":"zxq_yx_007@163.com","sentAt":"2017-05-16T13:55:18Z","receivedAt":"2017-05-16T13:56:53Z","isPatch":true,"sender":{"key":"zxq_yx_007@163.com","avatar":"https://avatars.githubusercontent.com/u/3981296?v=4"},"body":"\n\n> 在 2017年5月16日，20:10，Jan Viktorin <viktorin@rehivetech.com> 写道：\n> \n> Hello,\n> \n> with this patch applied to git 2.12, I could see:\n> \n> Use of uninitialized value $batch_size in numeric eq (==) at /usr/lib/git-core/git-send-email line 1679\n> \n> when --batch-size is NOT used. See below...\n> \n> On Sat, 13 May 2017 09:57:26 +0800\n> xiaoqiang zhao <zxq_yx_007@163.com> wrote:\n> \n>> Some email servers (e.g. smtp.163.com) limit the number emails to be\n>> sent per session(connection) and this will lead to a faliure when\n>> sending many messages.\n>> \n>> Teach send-email to disconnect after sending a number of messages\n>> (configurable via the --batch-size=<num> option), wait for a few\n>> seconds (configurable via the --relogin-delay=<seconds> option) and\n>> reconnect, to work around such a limit.\n>> \n>> Also add this two configure option for git config command.\n>> \n>> Note:\n>>   Re-authentication will happen every $<batch-size> messages, so it\n>> will be much more acceptable if you use some form of credential helper\n>> (e.g. the 'sendemail.smtppass' config option), otherwise you will have\n>> to retype password every time when asked.\n>> \n>> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>\n>> ---\n>> contrib/completion/git-completion.bash |  2 ++\n>> git-send-email.perl                    | 18 ++++++++++++++++++\n>> 2 files changed, 20 insertions(+)\n>> \n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index af658995d..29496353a 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -2608,6 +2608,8 @@ _git_config ()\n>>        sendemail.thread\n>>        sendemail.to\n>>        sendemail.validate\n>> +        sendemail.smtpbatchsize\n>> +        sendemail.smtprelogindelay\n>>        showbranch.default\n>>        status.relativePaths\n>>        status.showUntrackedFiles\n>> diff --git a/git-send-email.perl b/git-send-email.perl\n>> index eea0a517f..071d1ab9d 100755\n>> --- a/git-send-email.perl\n>> +++ b/git-send-email.perl\n>> @@ -81,6 +81,10 @@ git send-email --dump-aliases\n>>                                      This setting forces to use one of the listed mechanisms.\n>>     --smtp-debug            <0|1>  * Disable, enable Net::SMTP debug.\n>> \n>> +    --batch-size            <int>  * send max <int> message per connection.\n>> +    --relogin-delay         <int>  * delay <int> seconds between two successive login, default to 1,\n>> +                                     This option can only be used with --batch-size\n>> +\n>>   Automating:\n>>     --identity              <str>  * Use the sendemail.<id> options.\n>>     --to-cmd                <str>  * Email To: via `<str> \\$patch_path`\n>> @@ -153,6 +157,7 @@ my $have_email_valid = eval { require Email::Valid; 1 };\n>> my $have_mail_address = eval { require Mail::Address; 1 };\n>> my $smtp;\n>> my $auth;\n>> +my $num_sent = 0;\n>> \n>> # Regexes for RFC 2047 productions.\n>> my $re_token = qr/[^][()<>@,;:\\\\\"\\/?.= \\000-\\037\\177-\\377]+/;\n>> @@ -216,6 +221,7 @@ my ($cover_cc, $cover_to);\n>> my ($to_cmd, $cc_cmd);\n>> my ($smtp_server, $smtp_server_port, @smtp_server_options);\n>> my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);\n>> +my ($batch_size, $relogin_delay);\n>> my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);\n>> my ($validate, $confirm);\n>> my (@suppress_cc);\n>> @@ -247,6 +253,8 @@ my %config_settings = (\n>>     \"smtppass\" => \\$smtp_authpass,\n>>     \"smtpdomain\" => \\$smtp_domain,\n>>     \"smtpauth\" => \\$smtp_auth,\n>> +    \"smtpbatchsize\" => \\$batch_size,\n>> +    \"smtprelogindelay\" => \\$relogin_delay,\n>>     \"to\" => \\@initial_to,\n>>     \"tocmd\" => \\$to_cmd,\n>>     \"cc\" => \\@initial_cc,\n>> @@ -358,6 +366,8 @@ $rc = GetOptions(\n>>            \"force\" => \\$force,\n>>            \"xmailer!\" => \\$use_xmailer,\n>>            \"no-xmailer\" => sub {$use_xmailer = 0},\n>> +            \"batch-size=i\" => \\$batch_size,\n>> +            \"relogin-delay=i\" => \\$relogin_delay,\n>>     );\n>> \n>> usage() if $help;\n>> @@ -1664,6 +1674,14 @@ foreach my $t (@files) {\n>>        }\n>>    }\n>>    $message_id = undef;\n>> +    $num_sent++;\n>> +    if ($num_sent == $batch_size) {\n> \n> This is the line. I think, batch_size can be sometimes uninitialized\n> while this statement is executed.\n> \n> Regards\n> Jan\n\nThank you for reporting this，I will take a look .\n> \n>> +        $num_sent = 0;\n>> +        $smtp->quit if defined $smtp;\n>> +        undef $smtp;\n>> +        undef $auth;\n>> +        sleep($relogin_delay);\n>> +    }\n>> }\n>> \n>> # Execute a command (e.g. $to_cmd) to get a list of email addresses\n\n\n"},{"id":"319944","messageId":"CACBZZX76ZYc=BXoAc+stKu+6c7M8CY2V+z4Mg86Y9y9GqmC5dw@mail.gmail.com","threadId":"45950","inReplyTo":"2BB8B551-01A6-4470-9370-5B1A03EB96D0@163.com","subject":"Re: [PATCH v4] send-email: --batch-size to work around some SMTP server limit","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-16T17:43:02Z","receivedAt":"2017-05-16T17:43:29Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, May 16, 2017 at 3:55 PM, 赵小强 <zxq_yx_007@163.com> wrote:\n>\n>\n>> 在 2017年5月16日，20:10，Jan Viktorin <viktorin@rehivetech.com> 写道：\n>>\n>> Hello,\n>>\n>> with this patch applied to git 2.12, I could see:\n>>\n>> Use of uninitialized value $batch_size in numeric eq (==) at /usr/lib/git-core/git-send-email line 1679\n>>\n>> when --batch-size is NOT used. See below...\n>>\n>> On Sat, 13 May 2017 09:57:26 +0800\n>> xiaoqiang zhao <zxq_yx_007@163.com> wrote:\n>>\n>>> Some email servers (e.g. smtp.163.com) limit the number emails to be\n>>> sent per session(connection) and this will lead to a faliure when\n>>> sending many messages.\n>>>\n>>> Teach send-email to disconnect after sending a number of messages\n>>> (configurable via the --batch-size=<num> option), wait for a few\n>>> seconds (configurable via the --relogin-delay=<seconds> option) and\n>>> reconnect, to work around such a limit.\n>>>\n>>> Also add this two configure option for git config command.\n>>>\n>>> Note:\n>>>   Re-authentication will happen every $<batch-size> messages, so it\n>>> will be much more acceptable if you use some form of credential helper\n>>> (e.g. the 'sendemail.smtppass' config option), otherwise you will have\n>>> to retype password every time when asked.\n>>>\n>>> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>\n>>> ---\n>>> contrib/completion/git-completion.bash |  2 ++\n>>> git-send-email.perl                    | 18 ++++++++++++++++++\n>>> 2 files changed, 20 insertions(+)\n>>>\n>>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>>> index af658995d..29496353a 100644\n>>> --- a/contrib/completion/git-completion.bash\n>>> +++ b/contrib/completion/git-completion.bash\n>>> @@ -2608,6 +2608,8 @@ _git_config ()\n>>>        sendemail.thread\n>>>        sendemail.to\n>>>        sendemail.validate\n>>> +        sendemail.smtpbatchsize\n>>> +        sendemail.smtprelogindelay\n>>>        showbranch.default\n>>>        status.relativePaths\n>>>        status.showUntrackedFiles\n>>> diff --git a/git-send-email.perl b/git-send-email.perl\n>>> index eea0a517f..071d1ab9d 100755\n>>> --- a/git-send-email.perl\n>>> +++ b/git-send-email.perl\n>>> @@ -81,6 +81,10 @@ git send-email --dump-aliases\n>>>                                      This setting forces to use one of the listed mechanisms.\n>>>     --smtp-debug            <0|1>  * Disable, enable Net::SMTP debug.\n>>>\n>>> +    --batch-size            <int>  * send max <int> message per connection.\n>>> +    --relogin-delay         <int>  * delay <int> seconds between two successive login, default to 1,\n>>> +                                     This option can only be used with --batch-size\n>>> +\n>>>   Automating:\n>>>     --identity              <str>  * Use the sendemail.<id> options.\n>>>     --to-cmd                <str>  * Email To: via `<str> \\$patch_path`\n>>> @@ -153,6 +157,7 @@ my $have_email_valid = eval { require Email::Valid; 1 };\n>>> my $have_mail_address = eval { require Mail::Address; 1 };\n>>> my $smtp;\n>>> my $auth;\n>>> +my $num_sent = 0;\n>>>\n>>> # Regexes for RFC 2047 productions.\n>>> my $re_token = qr/[^][()<>@,;:\\\\\"\\/?.= \\000-\\037\\177-\\377]+/;\n>>> @@ -216,6 +221,7 @@ my ($cover_cc, $cover_to);\n>>> my ($to_cmd, $cc_cmd);\n>>> my ($smtp_server, $smtp_server_port, @smtp_server_options);\n>>> my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);\n>>> +my ($batch_size, $relogin_delay);\n>>> my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);\n>>> my ($validate, $confirm);\n>>> my (@suppress_cc);\n>>> @@ -247,6 +253,8 @@ my %config_settings = (\n>>>     \"smtppass\" => \\$smtp_authpass,\n>>>     \"smtpdomain\" => \\$smtp_domain,\n>>>     \"smtpauth\" => \\$smtp_auth,\n>>> +    \"smtpbatchsize\" => \\$batch_size,\n>>> +    \"smtprelogindelay\" => \\$relogin_delay,\n>>>     \"to\" => \\@initial_to,\n>>>     \"tocmd\" => \\$to_cmd,\n>>>     \"cc\" => \\@initial_cc,\n>>> @@ -358,6 +366,8 @@ $rc = GetOptions(\n>>>            \"force\" => \\$force,\n>>>            \"xmailer!\" => \\$use_xmailer,\n>>>            \"no-xmailer\" => sub {$use_xmailer = 0},\n>>> +            \"batch-size=i\" => \\$batch_size,\n>>> +            \"relogin-delay=i\" => \\$relogin_delay,\n>>>     );\n>>>\n>>> usage() if $help;\n>>> @@ -1664,6 +1674,14 @@ foreach my $t (@files) {\n>>>        }\n>>>    }\n>>>    $message_id = undef;\n>>> +    $num_sent++;\n>>> +    if ($num_sent == $batch_size) {\n>>\n>> This is the line. I think, batch_size can be sometimes uninitialized\n>> while this statement is executed.\n>>\n>> Regards\n>> Jan\n>\n> Thank you for reporting this，I will take a look .\n\nYou just need to initialize the variables you're using, see e.g. these\nexisting ones:\n\n    my ($quiet, $dry_run) = (0, 0);\n\nJust do the same for the ones you're adding.\n\n>>> +        $num_sent = 0;\n>>> +        $smtp->quit if defined $smtp;\n>>> +        undef $smtp;\n>>> +        undef $auth;\n>>> +        sleep($relogin_delay);\n>>> +    }\n>>> }\n>>>\n>>> # Execute a command (e.g. $to_cmd) to get a list of email addresses\n>\n>\n"},{"id":"319971","messageId":"xmqqd1b81hwf.fsf@gitster.mtv.corp.google.com","threadId":"45950","inReplyTo":"xmqqfug6wz0s.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v4] send-email: --batch-size to work around some SMTP server limit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-16T23:49:52Z","receivedAt":"2017-05-16T23:50:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> xiaoqiang zhao <zxq_yx_007@163.com> writes:\n> ...\n>> Note:\n>>    Re-authentication will happen every $<batch-size> messages, so it\n>> will be much more acceptable if you use some form of credential helper\n>> (e.g. the 'sendemail.smtppass' config option), otherwise you will have\n>> to retype password every time when asked.\n>\n> I think this deserves to be in the end-user documentation (i.e. the\n> part of your patch that updates Documentation/git-send-email.txt).\n\nAh, this came out to be rather obliqu, but you do need an update to\nthe documentation as part of this patch.\n\nThanks.\n"},{"id":"319972","messageId":"146427F1-BD3E-43FD-8C42-D0784E592508@163.com","threadId":"45950","inReplyTo":"xmqqd1b81hwf.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v4] send-email: --batch-size to work around some SMTP server limit","fromName":"赵小强","fromEmail":"zxq_yx_007@163.com","sentAt":"2017-05-17T00:03:11Z","receivedAt":"2017-05-17T00:04:07Z","isPatch":true,"sender":{"key":"zxq_yx_007@163.com","avatar":"https://avatars.githubusercontent.com/u/3981296?v=4"},"body":"\n\n> 在 2017年5月17日，07:49，Junio C Hamano <gitster@pobox.com> 写道：\n> \n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>> xiaoqiang zhao <zxq_yx_007@163.com> writes:\n>> ...\n>>> Note:\n>>>   Re-authentication will happen every $<batch-size> messages, so it\n>>> will be much more acceptable if you use some form of credential helper\n>>> (e.g. the 'sendemail.smtppass' config option), otherwise you will have\n>>> to retype password every time when asked.\n>> \n>> I think this deserves to be in the end-user documentation (i.e. the\n>> part of your patch that updates Documentation/git-send-email.txt).\n> \n> Ah, this came out to be rather obliqu, but you do need an update to\n> the documentation as part of this patch.\n> \n> Thanks.\n\nSure！\n\n"},{"id":"319973","messageId":"9B8174EC-E774-49FF-AB8A-2B8372AACE2E@163.com","threadId":"45950","inReplyTo":"CACBZZX76ZYc=BXoAc+stKu+6c7M8CY2V+z4Mg86Y9y9GqmC5dw@mail.gmail.com","subject":"Re: [PATCH v4] send-email: --batch-size to work around some SMTP server limit","fromName":"赵小强","fromEmail":"zxq_yx_007@163.com","sentAt":"2017-05-17T00:04:18Z","receivedAt":"2017-05-17T00:04:46Z","isPatch":true,"sender":{"key":"zxq_yx_007@163.com","avatar":"https://avatars.githubusercontent.com/u/3981296?v=4"},"body":"\n\n在 2017年5月17日，01:43，Ævar Arnfjörð Bjarmason <avarab@gmail.com> 写道：\n\n>>> Regards\n>>> Jan\n>> \n>> Thank you for reporting this，I will take a look .\n> \n> You just need to initialize the variables you're using, see e.g. these\n> existing ones:\n> \n>    my ($quiet, $dry_run) = (0, 0);\n> \n> Just do the same for the ones you're adding.\n\nYes，has to be.\n\n"}]}