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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]