* [PATCH] Add sendmail -f support to git-send-email.
@ 2007-04-10 22:02 Robin H. Johnson
2007-04-10 22:02 ` [PATCH] Make envelope-sender fully configurable Robin H. Johnson
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Robin H. Johnson @ 2007-04-10 22:02 UTC (permalink / raw)
To: git; +Cc: junkio, Robin, H.Johnson, robbat2
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
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH] Make envelope-sender fully configurable. 2007-04-10 22:02 [PATCH] Add sendmail -f support to git-send-email Robin H. Johnson @ 2007-04-10 22:02 ` Robin H. Johnson 2007-04-10 22:06 ` [PATCH] Add sendmail -f support to git-send-email Robin H. Johnson 2007-04-10 22:38 ` Frank Lichtenheld 2 siblings, 0 replies; 9+ messages in thread From: Robin H. Johnson @ 2007-04-10 22:02 UTC (permalink / raw) To: git; +Cc: junkio, Robin, H.Johnson, robbat2 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_addr,'-i', map { extract_valid_address($_) } @recipients); + my @sendmail_args = ('-f',$envelope_sender,'-i', map { extract_valid_address($_) } @recipients); if ($dry_run) { # We don't want to send the email. + $smtp = !($smtp_server =~ m#^/#); } elsif ($smtp_server =~ m#^/#) { my $pid = open my $sm, '|-'; defined $pid or die $!; @@ -477,7 +485,7 @@ X-Mailer: git-send-email $gitversion } else { require Net::SMTP; $smtp ||= Net::SMTP->new( $smtp_server ); - $smtp->mail( $from ) or die $smtp->message; + $smtp->mail( $envelope_sender ) or die $smtp->message; $smtp->to( @recipients ) or die $smtp->message; $smtp->data or die $smtp->message; $smtp->datasend("$header\n$message") or die $smtp->message; @@ -489,17 +497,15 @@ X-Mailer: git-send-email $gitversion } else { print "OK. Log says:\nDate: $date\n"; if ($smtp) { - print "Server: $smtp_server\n"; + print "SMTP Server: $smtp_server\n"; + print "SMTP MAIL FROM: $envelope_sender\n"; + print "SMTP RCPT TO: ".join(', ',@recipients)."\n"; } else { print "Sendmail: $smtp_server\n"; - my $s = ""; - foreach my $a (@sendmail_args) { - $s .= " \'".$a."\'"; - } - print "Args:$s\n"; + print "Args: '".join("' '",@sendmail_args)."'\n"; } print "From: $from\nSubject: $subject\nCc: $cc\nTo: $to\n\n"; - if ($smtp) { + if ($smtp and not $dry_run) { print "Result: ", $smtp->code, ' ', ($smtp->message =~ /\n([^\n]+\n)$/s), "\n"; } else { @@ -616,7 +622,7 @@ sub cleanup_compose_files() { } -$smtp->quit if $smtp; +$smtp->quit if ($smtp and not $dry_run); sub unique_email_list(@) { my %seen; -- 1.5.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Add sendmail -f support to git-send-email. 2007-04-10 22:02 [PATCH] Add sendmail -f support to git-send-email Robin H. Johnson 2007-04-10 22:02 ` [PATCH] Make envelope-sender fully configurable Robin H. Johnson @ 2007-04-10 22:06 ` Robin H. Johnson 2007-04-10 22:38 ` Frank Lichtenheld 2 siblings, 0 replies; 9+ messages in thread From: Robin H. Johnson @ 2007-04-10 22:06 UTC (permalink / raw) To: Robin H. Johnson; +Cc: git, junkio [-- Attachment #1: Type: text/plain, Size: 500 bytes --] 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). -- Robin Hugh Johnson E-Mail : robbat2@orbis-terrarum.net Home Page : http://www.orbis-terrarum.net/?l=people.robbat2 ICQ# : 30269588 or 41961639 GnuPG FP : 11AC BA4F 4778 E3F6 E4ED F38E B27B 944E 3488 4E85 [-- Attachment #2: Type: application/pgp-signature, Size: 321 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add sendmail -f support to git-send-email. 2007-04-10 22:02 [PATCH] Add sendmail -f support to git-send-email Robin H. Johnson 2007-04-10 22:02 ` [PATCH] Make envelope-sender fully configurable Robin H. Johnson 2007-04-10 22:06 ` [PATCH] Add sendmail -f support to git-send-email Robin H. Johnson @ 2007-04-10 22:38 ` Frank Lichtenheld 2007-04-10 22:42 ` Robin H. Johnson 2007-04-10 23:00 ` Junio C Hamano 2 siblings, 2 replies; 9+ messages in thread From: Frank Lichtenheld @ 2007-04-10 22:38 UTC (permalink / raw) To: Robin H. Johnson; +Cc: git, junkio On Tue, Apr 10, 2007 at 03:02:13PM -0700, Robin H. Johnson wrote: > 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. 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/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add sendmail -f support to git-send-email. 2007-04-10 22:38 ` Frank Lichtenheld @ 2007-04-10 22:42 ` Robin H. Johnson 2007-04-10 23:00 ` Junio C Hamano 1 sibling, 0 replies; 9+ messages in thread From: Robin H. Johnson @ 2007-04-10 22:42 UTC (permalink / raw) To: git, junkio [-- Attachment #1: Type: text/plain, Size: 607 bytes --] On Wed, Apr 11, 2007 at 12:38:27AM +0200, Frank Lichtenheld wrote: > 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. In those cases, the sendmail binary should fail gracefully, and then you know that at least your email isn't lost into the ether. -- 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 [-- Attachment #2: Type: application/pgp-signature, Size: 321 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add sendmail -f support to git-send-email. 2007-04-10 22:38 ` Frank Lichtenheld 2007-04-10 22:42 ` Robin H. Johnson @ 2007-04-10 23:00 ` Junio C Hamano 2007-04-11 0:38 ` Frank Lichtenheld 1 sibling, 1 reply; 9+ messages in thread From: Junio C Hamano @ 2007-04-10 23:00 UTC (permalink / raw) To: Frank Lichtenheld; +Cc: git, Robin H. Johnson Frank Lichtenheld <frank@lichtenheld.de> writes: > On Tue, Apr 10, 2007 at 03:02:13PM -0700, Robin H. Johnson wrote: >> 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. > > 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. 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? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add sendmail -f support to git-send-email. 2007-04-10 23:00 ` Junio C Hamano @ 2007-04-11 0:38 ` Frank Lichtenheld 2007-04-11 5:18 ` Junio C Hamano 2007-04-11 8:57 ` Lukas Sandström 0 siblings, 2 replies; 9+ messages in thread From: Frank Lichtenheld @ 2007-04-11 0:38 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Tue, Apr 10, 2007 at 04:00:57PM -0700, Junio C Hamano wrote: > Frank Lichtenheld <frank@lichtenheld.de> writes: > > > On Tue, Apr 10, 2007 at 03:02:13PM -0700, Robin H. Johnson wrote: > >> 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. > > > > 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. > > 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? 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/ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add sendmail -f support to git-send-email. 2007-04-11 0:38 ` Frank Lichtenheld @ 2007-04-11 5:18 ` Junio C Hamano 2007-04-11 8:57 ` Lukas Sandström 1 sibling, 0 replies; 9+ messages in thread From: Junio C Hamano @ 2007-04-11 5:18 UTC (permalink / raw) To: Frank Lichtenheld; +Cc: git Frank Lichtenheld <frank@lichtenheld.de> writes: >> 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? > > 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 :) 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. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add sendmail -f support to git-send-email. 2007-04-11 0:38 ` Frank Lichtenheld 2007-04-11 5:18 ` Junio C Hamano @ 2007-04-11 8:57 ` Lukas Sandström 1 sibling, 0 replies; 9+ messages in thread From: Lukas Sandström @ 2007-04-11 8:57 UTC (permalink / raw) To: git; +Cc: Junio C Hamano, frank Frank Lichtenheld wrote: > On Tue, Apr 10, 2007 at 04:00:57PM -0700, Junio C Hamano wrote: >> Frank Lichtenheld <frank@lichtenheld.de> writes: >> 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? > > 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, 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-04-11 9:18 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-04-10 22:02 [PATCH] Add sendmail -f support to git-send-email Robin H. Johnson 2007-04-10 22:02 ` [PATCH] Make envelope-sender fully configurable Robin H. Johnson 2007-04-10 22:06 ` [PATCH] Add sendmail -f support to git-send-email Robin H. Johnson 2007-04-10 22:38 ` Frank Lichtenheld 2007-04-10 22:42 ` Robin H. Johnson 2007-04-10 23:00 ` Junio C Hamano 2007-04-11 0:38 ` Frank Lichtenheld 2007-04-11 5:18 ` Junio C Hamano 2007-04-11 8:57 ` Lukas Sandström
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).