git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] send-email: new option to walkaround email server limits

From
Paolo Bonzini <pbonzini@redhat.com>
Date
May 2, 2017, 09:32 UTC
Message-ID
<6bef306b-0bfb-2314-50fd-9c152888b344@redhat.com>
In-Reply-To
<20170429122632.7122-1-zxq_yx_007@163.com>
On 29/04/2017 14:26, xiaoqiang zhao wrote:
Show 6 quoted lines
> Some email server(e.g. smtp.163.com) limits a fixed number emails to be send per
> session(connection) and this will lead to a send faliure.
> With --split <num> option, a auto reconnection will occur when number of sended
> email reaches <num> and the problem is solved.
> 
> Signed-off-by: xiaoqiang zhao <zxq_yx_007@163.com>

I think you should also add a matching configuration option, or you are going to forget it on the command line sooner or later!

Paolo
Show 83 quoted lines
> ---
>  git-send-email.perl | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/git-send-email.perl b/git-send-email.perl
> index eea0a517f..0de9b7058 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -81,6 +81,8 @@ git send-email --dump-aliases
>                                       This setting forces to use one of the listed mechanisms.
>      --smtp-debug            <0|1>  * Disable, enable Net::SMTP debug.
>  
> +    --split                 <int>  * send \$num message per connection.
> +
>    Automating:
>      --identity              <str>  * Use the sendemail.<id> options.
>      --to-cmd                <str>  * Email To: via `<str> \$patch_path`
> @@ -153,6 +155,7 @@ my $have_email_valid = eval { require Email::Valid; 1 };
>  my $have_mail_address = eval { require Mail::Address; 1 };
>  my $smtp;
>  my $auth;
> +my $send_count = 0;
>  
>  # Regexes for RFC 2047 productions.
>  my $re_token = qr/[^][()<>@,;:\\"\/?.= \000-\037\177-\377]+/;
> @@ -186,6 +189,7 @@ my $format_patch;
>  my $compose_filename;
>  my $force = 0;
>  my $dump_aliases = 0;
> +my $split = 0;
>  
>  # Handle interactive edition of files.
>  my $multiedit;
> @@ -358,6 +362,7 @@ $rc = GetOptions(
>  		    "force" => \$force,
>  		    "xmailer!" => \$use_xmailer,
>  		    "no-xmailer" => sub {$use_xmailer = 0},
> +		    "split=i" => \$split,
>  	 );
>  
>  usage() if $help;
> @@ -1158,10 +1163,15 @@ sub smtp_host_string {
>  # (smtp_user was not specified), and 0 otherwise.
>  
>  sub smtp_auth_maybe {
> -	if (!defined $smtp_authuser || $auth) {
> +	if (!defined $smtp_authuser || $send_count != 0) {
>  		return 1;
>  	}
>  
> +	if ($auth && $send_count == 0) {
> +		print "Auth use saved password. \n";
> +		return !!$smtp->auth($smtp_authuser, $smtp_authpass);
> +	}
> +
>  	# Workaround AUTH PLAIN/LOGIN interaction defect
>  	# with Authen::SASL::Cyrus
>  	eval {
> @@ -1187,6 +1197,7 @@ sub smtp_auth_maybe {
>  		'password' => $smtp_authpass
>  	}, sub {
>  		my $cred = shift;
> +		$smtp_authpass = $cred->{'password'};
>  
>  		if ($smtp_auth) {
>  			my $sasl = Authen::SASL->new(
> @@ -1442,6 +1453,15 @@ EOF
>  		}
>  	}
>  
> +	$send_count++;
> +	if ($send_count == $split) {
> +		$smtp->quit;
> +		$smtp = undef;
> +		$send_count = 0;
> +		print "Reconnect SMTP server required. \n";
> +
> +	}
> +
>  	return 1;
>  }
>  
> 
Previous: Ævar Arnfjörð BjarmasonNext: 赵小强
Message 8 of 9 in “send-email: new option to walkaround email server limits”
  1. send-email: new option to walkaround email server limitsxiaoqiang zhao, Apr 29, 2017
  2. Junio C HamanoMay 1, 2017
  3. 赵小强May 1, 2017
  4. Ævar Arnfjörð BjarmasonMay 2, 2017
  5. Junio C HamanoMay 4, 2017
  6. Ramkumar RamachandraMay 4, 2017
  7. Ævar Arnfjörð BjarmasonMay 4, 2017
  8. Paolo BonziniMay 2, 2017
  9. 赵小强May 4, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.