* [PATCH] send-email: Allow sleeping between sending mails
@ 2007-12-08 17:12 Dan Nicholson
0 siblings, 0 replies; only message in thread
From: Dan Nicholson @ 2007-12-08 17:12 UTC (permalink / raw
To: git
Sometimes when sending many mails, the thread appears out of order for
the recipient. This adds a simple workaround by sleeping between sending
mails. This is controlled by the option --sleep, which defaults to 0.
Since the perl builtin function sleep is used, only integer granularity
is offered. GetOptions seems to perform the necessary checking for this.
Signed-off-by: Dan Nicholson <dbn.lists@gmail.com>
---
Documentation/git-send-email.txt | 5 +++++
git-send-email.perl | 14 +++++++++++++-
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 659215a..45341db 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -71,6 +71,11 @@ The --cc option must be repeated for each user you want on the cc list.
Default is the value of 'sendemail.signedoffcc' configuration value;
if that is unspecified, default to --signed-off-by-cc.
+--sleep::
+ Specify an integer number of seconds to sleep between sending
+ mails. This can help when sending many mails at once and they
+ appear out of order for the recipient. Defaults to 0.
+
--quiet::
Make git-send-email less verbose. One line per email should be
all that is output.
diff --git a/git-send-email.perl b/git-send-email.perl
index 76baa8e..a105306 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -100,6 +100,9 @@ Options:
--envelope-sender Specify the envelope sender used to send the emails.
+ --sleep Specify an integer number of seconds to sleep between
+ sending mails. Defaults to 0.
+
EOT
exit(1);
}
@@ -158,6 +161,7 @@ my (@to,@cc,@initial_cc,@bcclist,@xh,
$initial_reply_to,$initial_subject,@files,$author,$sender,$compose,$time);
my $envelope_sender;
+my $mail_index;
# Example reply to:
#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
@@ -171,7 +175,7 @@ if ($@) {
}
# Behavior modification variables
-my ($quiet, $dry_run) = (0, 0);
+my ($quiet, $dry_run, $sleep_time) = (0, 0, 0);
# Variables with corresponding config settings
my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
@@ -222,6 +226,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
"dry-run" => \$dry_run,
"envelope-sender=s" => \$envelope_sender,
"thread!" => \$thread,
+ "sleep=i" => \$sleep_time,
);
unless ($rc) {
@@ -669,6 +674,7 @@ X-Mailer: git-send-email $gitversion
$reply_to = $initial_reply_to;
$references = $initial_reply_to || '';
$subject = $initial_subject;
+$mail_index = 0;
foreach my $t (@files) {
open(F,"<",$t) or die "can't open file $t";
@@ -803,6 +809,12 @@ foreach my $t (@files) {
$references = "$message_id";
}
}
+
+ # sleep if requested and there are any mails left
+ if ($sleep_time > 0 && $mail_index < $#files) {
+ sleep $sleep_time;
+ }
+ $mail_index++;
}
if ($compose) {
--
1.5.3.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-12-08 17:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-08 17:12 [PATCH] send-email: Allow sleeping between sending mails Dan Nicholson
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).