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

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Cc: <junkio@...>, <Robin@...>, <H.Johnson@...>, <robbat2@...>
Date: Tuesday, April 10, 2007 - 6:02 pm

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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Add sendmail -f support to git-send-email., Robin H. Johnson, (Tue Apr 10, 6:02 pm)
Re: [PATCH] Add sendmail -f support to git-send-email., Frank Lichtenheld, (Tue Apr 10, 6:38 pm)
Re: [PATCH] Add sendmail -f support to git-send-email., Junio C Hamano, (Tue Apr 10, 7:00 pm)
Re: [PATCH] Add sendmail -f support to git-send-email., Frank Lichtenheld, (Tue Apr 10, 8:38 pm)
Re: [PATCH] Add sendmail -f support to git-send-email., Junio C Hamano, (Wed Apr 11, 1:18 am)
Re: [PATCH] Add sendmail -f support to git-send-email., Robin H. Johnson, (Tue Apr 10, 6:42 pm)
Re: [PATCH] Add sendmail -f support to git-send-email., Robin H. Johnson, (Tue Apr 10, 6:06 pm)
[PATCH] Make envelope-sender fully configurable., Robin H. Johnson, (Tue Apr 10, 6:02 pm)