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

[RFC/PATCH 3/2 (squash!)] git-send-email: Warn about rejected automatically added recipients

From
Jakub Narebski <jnareb@gmail.com>
Date
May 6, 2011, 11:22 UTC
Message-ID
<201105061322.24736.jnareb@gmail.com>
In-Reply-To
<201105051601.46012.jnareb@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
On Thu, 5 May 2011, Jakub Narebski wrote:
> On Wed, 4 May 2011, Jeff King wrote:
>> On Wed, May 04, 2011 at 06:12:08PM +0200, Jakub Narebski wrote:
>>> On Fri, 15 Apr 2011, Jeff King wrote:
Show 8 quoted lines
>>>> [...] You could probably remember which recipients are "important"
>>>> (i.e., given on the command line) and which were pulled automatically
>>>> from the commit information, and then feed each recipient individually.
>>>> If important ones fail, abort the message. If an unimportant one fails,
>>>> send the message anyway, but remember the bad address and report the
>>>> error at the end.
> 
> It does not warn about bad addresses from body, and there are no tests yet!

Now it does warn, though I don't know if we should warn after each message, or all together at the end, and if we should warn only about _new_ addresses.

Still no tests, and no idea how to write one...

Also if it is to be standalone commit, it needs better commit message. But if it is to squashed with previous, it doesn't ;-)

 git-send-email.perl |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index e758fd9..b8d4fb9 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1136,11 +1136,20 @@ X-Mailer: git-send-email $gitversion
 
 		$smtp->mail( $raw_from ) or die $smtp->message;
 		$smtp->to( @recipients ) or die $smtp->message;
-		$smtp->to( @recipients_extra, { Notify => ['NEVER'], SkipBad => 1 });
+		my @good_recips =
+			$smtp->to( @recipients_extra, { Notify => ['NEVER'], SkipBad => 1 });
 		$smtp->data or die $smtp->message;
 		$smtp->datasend("$header\n$message") or die $smtp->message;
 		$smtp->dataend() or die $smtp->message;
 		$smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message;
+
+		%seen = ();
+		unique_email_list(\%seen, @good_recips);
+		# bad recipients are those not seen on list of good recipients
+		my @bad_recips = unique_email_list(\%seen, @recipients_extra);
+		@bad_recips and
+			warn "W: The following addresses added from body were rejected:\n\t".
+				join("\n\t", @bad_recips)."\n";
 	}
 	if ($quiet) {
 		printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
-- 
1.7.5
Previous: Jakub NarebskiNext: Jakub Narebski
Message 8 of 9 in “RFC: git send-email and error handling”
  1. Paul GortmakerApr 14, 2011
  2. Jeff KingApr 14, 2011
  3. Paul GortmakerApr 15, 2011
  4. Jeff KingApr 15, 2011
  5. git-send-email: Remember sources of Cc addressesJakub Narebski, May 4, 2011
  6. Jeff KingMay 4, 2011
  7. 2/2 git-send-email: Do not require that addresses added from body be validJakub Narebski, May 5, 2011
  8. 3/2 git-send-email: Warn about rejected automatically added recipientsJakub Narebski, May 6, 2011
  9. Jakub NarebskiMay 7, 2011

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.