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

Previous thread: Envelope sender patches for git-send-email by Robin H. Johnson on Tuesday, April 10, 2007 - 6:00 pm. (1 message)

Next thread: MinGW port of git downloadable from anywhere? by H. Peter Anvin on Tuesday, April 10, 2007 - 6:51 pm. (1 message)
To: <git@...>
Cc: <junkio@...>, <robbat2@...>, <H.Johnson@...>, <Robin@...>
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: Robin H. Johnson <robbat2@...>
Cc: <junkio@...>, <git@...>
Date: Tuesday, April 10, 2007 - 6:38 pm

At least some MTAs (exim is the one I know for sure) can restrict -f
usage to some users and deny it for others. Don't know how much this
would really be a problem, but using -f unconditionally might be a bad
idea none-the-less.

Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
-

To: Frank Lichtenheld <frank@...>
Cc: Robin H. Johnson <robbat2@...>, <git@...>
Date: Tuesday, April 10, 2007 - 7:00 pm

I thought I saw the '-f' patch somewhere on the list in the last
several weeks and there was a discussion on this topic that
followed the patch. Am I hallucinating, or was it not applied
because there were some issues?

-

To: Junio C Hamano <junkio@...>
Cc: <git@...>
Date: Tuesday, April 10, 2007 - 8:38 pm

Can't find anything in the archives. So either I completly suck
at searching, or it is at least several months old, or you
are hallucinating :)

Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
-

To: <git@...>
Cc: Junio C Hamano <junkio@...>, <frank@...>
Date: Wednesday, April 11, 2007 - 4:57 am

Se the thread starting with the mail
Message-ID: <874poc88ix.fsf@rho.meyering.net>

http://thread.gmane.org/gmane.comp.version-control.git/42927/

The discussion was about hooks--update, not git-send-mail.

/Lukas
-

To: Frank Lichtenheld <frank@...>
Cc: <git@...>
Date: Wednesday, April 11, 2007 - 1:18 am

It was the thread about update-hook that sends e-mail; the
discussion ends here:

http://thread.gmane.org/gmane.comp.version-control.git/42927/focus=42996

The patch was from Jim Meyering that made the script to
unconditionally pass -f '$envelope_sender'; it was not applied
because the whole e-mail sending business was removed from the
update hook.

We seem to do a "-f '$envelope_sender'" in the example 'post-receive'
hook only when the configuration tells it to, so probably it is
a good idea to follow suit in this program.

-

To: <junkio@...>, <git@...>
Date: Tuesday, April 10, 2007 - 6:42 pm

In those cases, the sendmail binary should fail gracefully, and then you
know that at least your email isn't lost into the ether.

--=20
Robin Hugh Johnson
Gentoo Linux Developer & Council Member
E-Mail : robbat2@gentoo.org
GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85

To: Robin H. Johnson <robbat2@...>
Cc: <junkio@...>, <git@...>
Date: Tuesday, April 10, 2007 - 6:06 pm

Weird mail header here:
"Cc: junkio@cox.net, Robin@orbis-terrarum.net, H.Johnson@orbis-terrarum.net=
, robbat2@gentoo.org"

Looks like git-send-email didn't put the quotation marks around the CC
address, so my MTA broke it up (and tried to expand each part locally).

--=20
Robin Hugh Johnson
E-Mail : robbat2@orbis-terrarum.net
Home Page : http://www.orbis-terrarum.net/?l=3Dpeople.robbat2
ICQ# : 30269588 or 41961639
GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85

To: <git@...>
Cc: <junkio@...>, <robbat2@...>, <H.Johnson@...>, <Robin@...>
Date: Tuesday, April 10, 2007 - 6:02 pm

From: Robin H. Johnson <robbat2@gentoo.org>

This patch makes envelope sender fully configurable, and also allows it to be
use with Net::SMTP instead of just the sendmail binary.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
---
git-send-email.perl | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 2436aec..133a844 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -76,6 +76,8 @@ Options:
--quiet Make git-send-email less verbose. One line per email
should be all that is output.

+ --envelope-sender Specify the sender address used for the email envelope.
+
EOT
exit(1);
}
@@ -130,7 +132,8 @@ my $compose_filename = ".msg.$$";

# Variables we fill in automatically, or via prompting:
my (@to,@cc,@initial_cc,@bcclist,@xh,
- $initial_reply_to,$initial_subject,@files,$from,$compose,$time);
+ $initial_reply_to,$initial_subject,@files,$from,$compose,$time,
+ $envelope_sender);

# Behavior modification variables
my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc,
@@ -169,6 +172,7 @@ my $rc = GetOptions("from=s" => \$from,
"bcc=s" => \@bcclist,
"chain-reply-to!" => \$chain_reply_to,
"smtp-server=s" => \$smtp_server,
+ "envelope-sender=s" => \$envelope_sender,
"compose" => \$compose,
"quiet" => \$quiet,
"suppress-from" => \$suppress_from,
@@ -445,7 +449,10 @@ sub send_message
my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
$from = "\"$name\"$addr";
}
- my ($author_addr) = ($from =~ /^.*?\s+<(.*?)>/);
+ if(!defined $envelope_sender or -z $envelope_sender) {
+ $from =~ /^.*?\s+<(.*?)>/;
+ $envelope_sender = $1;
+ }
my $header = "From: $from
To: $to
Cc: $cc
@@ -463,9 +470,10 @@ X-Mailer: git-send-email $gitversion
$header .= join("\n", @xh) . "\n";
}

- my @sendmail_args = ('-f',$author...

Previous thread: Envelope sender patches for git-send-email by Robin H. Johnson on Tuesday, April 10, 2007 - 6:00 pm. (1 message)

Next thread: MinGW port of git downloadable from anywhere? by H. Peter Anvin on Tuesday, April 10, 2007 - 6:51 pm. (1 message)