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

[PATCH] Add sendmail -f support to git-send-email.

From
Robin H. Johnson <robbat2@gentoo.org>
Date
Apr 10, 2007, 22:02 UTC
Message-ID
<11762425341841-git-send-email-robbat2@gentoo.org>

Some mailing lists use the envelope sender instead of the actual from address, and this can be broken in git-send-email. This patch sets the -f argument to the sendmail binary, using the address of the patch author.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
---
 git-send-email.perl |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index ae50990..2436aec 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -34,7 +34,6 @@ sub readline {
 }
 package main;
 
-
 sub usage {
 	print <<EOT;
 git-send-email [options] <file | directory>...
@@ -446,6 +445,7 @@ sub send_message
 		my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
 		$from = "\"$name\"$addr";
 	}
+	my ($author_addr) = ($from =~ /^.*?\s+<(.*?)>/);
 	my $header = "From: $from
 To: $to
 Cc: $cc
@@ -462,16 +462,15 @@ X-Mailer: git-send-email $gitversion
 	if (@xh) {
 		$header .= join("\n", @xh) . "\n";
 	}
-
+	
+	my @sendmail_args = ('-f',$author_addr,'-i', map { extract_valid_address($_) } @recipients);
 	if ($dry_run) {
 		# We don't want to send the email.
 	} elsif ($smtp_server =~ m#^/#) {
 		my $pid = open my $sm, '|-';
 		defined $pid or die $!;
 		if (!$pid) {
-			exec($smtp_server,'-i',
-			     map { extract_valid_address($_) }
-			     @recipients) or die $!;
+			exec($smtp_server, @sendmail_args) or die $!;
 		}
 		print $sm "$header\n$message";
 		close $sm or die $?;
@@ -493,6 +492,11 @@ X-Mailer: git-send-email $gitversion
 			print "Server: $smtp_server\n";
 		} else {
 			print "Sendmail: $smtp_server\n";
+			my $s = "";
+			foreach my $a (@sendmail_args) {
+				$s .= " \'".$a."\'";
+			}
+			print "Args:$s\n";
 		}
 		print "From: $from\nSubject: $subject\nCc: $cc\nTo: $to\n\n";
 		if ($smtp) {
-- 
1.5.1
Next: Robin H. Johnson
Message 1 of 9 in “Add sendmail -f support to git-send-email.”
  1. Add sendmail -f support to git-send-email.Robin H. Johnson, Apr 10, 2007
  2. Make envelope-sender fully configurable.Robin H. Johnson, Apr 10, 2007
  3. Robin H. JohnsonApr 10, 2007
  4. Frank LichtenheldApr 10, 2007
  5. Robin H. JohnsonApr 10, 2007
  6. Junio C HamanoApr 10, 2007
  7. Frank LichtenheldApr 11, 2007
  8. Junio C HamanoApr 11, 2007
  9. Lukas SandströmApr 11, 2007

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.