{"thread":{"id":"7600","subject":"Re: [PATCH] Add sendmail -f support to git-send-email.","startedAt":"2007-04-10T22:02:13Z","lastAt":"2007-04-11T08:57:43Z","messageCount":9,"participants":["Robin H. Johnson","Frank Lichtenheld","Junio C Hamano","Lukas Sandström"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"39063","messageId":"11762425341841-git-send-email-robbat2@gentoo.org","threadId":"7600","inReplyTo":null,"subject":"[PATCH] Add sendmail -f support to git-send-email.","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2007-04-10T22:02:13Z","receivedAt":"2007-04-10T22:02:13Z","isPatch":true,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"Some mailing lists use the envelope sender instead of the actual from address,\nand this can be broken in git-send-email. This patch sets the -f argument to\nthe sendmail binary, using the address of the patch author.\n\nSigned-off-by: Robin H. Johnson <robbat2@gentoo.org>\n---\n git-send-email.perl |   14 +++++++++-----\n 1 files changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex ae50990..2436aec 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -34,7 +34,6 @@ sub readline {\n }\n package main;\n \n-\n sub usage {\n \tprint <<EOT;\n git-send-email [options] <file | directory>...\n@@ -446,6 +445,7 @@ sub send_message\n \t\tmy ($name, $addr) = ($from =~ /^(.*?)(\\s+<.*)/);\n \t\t$from = \"\\\"$name\\\"$addr\";\n \t}\n+\tmy ($author_addr) = ($from =~ /^.*?\\s+<(.*?)>/);\n \tmy $header = \"From: $from\n To: $to\n Cc: $cc\n@@ -462,16 +462,15 @@ X-Mailer: git-send-email $gitversion\n \tif (@xh) {\n \t\t$header .= join(\"\\n\", @xh) . \"\\n\";\n \t}\n-\n+\t\n+\tmy @sendmail_args = ('-f',$author_addr,'-i', map { extract_valid_address($_) } @recipients);\n \tif ($dry_run) {\n \t\t# We don't want to send the email.\n \t} elsif ($smtp_server =~ m#^/#) {\n \t\tmy $pid = open my $sm, '|-';\n \t\tdefined $pid or die $!;\n \t\tif (!$pid) {\n-\t\t\texec($smtp_server,'-i',\n-\t\t\t     map { extract_valid_address($_) }\n-\t\t\t     @recipients) or die $!;\n+\t\t\texec($smtp_server, @sendmail_args) or die $!;\n \t\t}\n \t\tprint $sm \"$header\\n$message\";\n \t\tclose $sm or die $?;\n@@ -493,6 +492,11 @@ X-Mailer: git-send-email $gitversion\n \t\t\tprint \"Server: $smtp_server\\n\";\n \t\t} else {\n \t\t\tprint \"Sendmail: $smtp_server\\n\";\n+\t\t\tmy $s = \"\";\n+\t\t\tforeach my $a (@sendmail_args) {\n+\t\t\t\t$s .= \" \\'\".$a.\"\\'\";\n+\t\t\t}\n+\t\t\tprint \"Args:$s\\n\";\n \t\t}\n \t\tprint \"From: $from\\nSubject: $subject\\nCc: $cc\\nTo: $to\\n\\n\";\n \t\tif ($smtp) {\n-- \n1.5.1\n"},{"id":"39062","messageId":"1176242534838-git-send-email-robbat2@gentoo.org","threadId":"7600","inReplyTo":"11762425341841-git-send-email-robbat2@gentoo.org","subject":"[PATCH] Make envelope-sender fully configurable.","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2007-04-10T22:02:14Z","receivedAt":"2007-04-10T22:02:14Z","isPatch":true,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"From: Robin H. Johnson <robbat2@gentoo.org>\n\nThis patch makes envelope sender fully configurable, and also allows it to be\nuse with Net::SMTP instead of just the sendmail binary.\n\nSigned-off-by: Robin H. Johnson <robbat2@gentoo.org>\n---\n git-send-email.perl |   30 ++++++++++++++++++------------\n 1 files changed, 18 insertions(+), 12 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 2436aec..133a844 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -76,6 +76,8 @@ Options:\n    --quiet\t  Make git-send-email less verbose.  One line per email\n                   should be all that is output.\n \n+   --envelope-sender Specify the sender address used for the email envelope.\n+\n EOT\n \texit(1);\n }\n@@ -130,7 +132,8 @@ my $compose_filename = \".msg.$$\";\n \n # Variables we fill in automatically, or via prompting:\n my (@to,@cc,@initial_cc,@bcclist,@xh,\n-\t$initial_reply_to,$initial_subject,@files,$from,$compose,$time);\n+\t$initial_reply_to,$initial_subject,@files,$from,$compose,$time,\n+\t$envelope_sender);\n \n # Behavior modification variables\n my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc,\n@@ -169,6 +172,7 @@ my $rc = GetOptions(\"from=s\" => \\$from,\n \t\t    \"bcc=s\" => \\@bcclist,\n \t\t    \"chain-reply-to!\" => \\$chain_reply_to,\n \t\t    \"smtp-server=s\" => \\$smtp_server,\n+\t\t    \"envelope-sender=s\" => \\$envelope_sender,\n \t\t    \"compose\" => \\$compose,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"suppress-from\" => \\$suppress_from,\n@@ -445,7 +449,10 @@ sub send_message\n \t\tmy ($name, $addr) = ($from =~ /^(.*?)(\\s+<.*)/);\n \t\t$from = \"\\\"$name\\\"$addr\";\n \t}\n-\tmy ($author_addr) = ($from =~ /^.*?\\s+<(.*?)>/);\n+\tif(!defined $envelope_sender or -z $envelope_sender) {\n+\t\t$from =~ /^.*?\\s+<(.*?)>/;\n+\t\t$envelope_sender = $1;\n+\t}\n \tmy $header = \"From: $from\n To: $to\n Cc: $cc\n@@ -463,9 +470,10 @@ X-Mailer: git-send-email $gitversion\n \t\t$header .= join(\"\\n\", @xh) . \"\\n\";\n \t}\n \t\n-\tmy @sendmail_args = ('-f',$author_addr,'-i', map { extract_valid_address($_) } @recipients);\n+\tmy @sendmail_args = ('-f',$envelope_sender,'-i', map { extract_valid_address($_) } @recipients);\n \tif ($dry_run) {\n \t\t# We don't want to send the email.\n+\t\t$smtp = !($smtp_server =~  m#^/#);\n \t} elsif ($smtp_server =~ m#^/#) {\n \t\tmy $pid = open my $sm, '|-';\n \t\tdefined $pid or die $!;\n@@ -477,7 +485,7 @@ X-Mailer: git-send-email $gitversion\n \t} else {\n \t\trequire Net::SMTP;\n \t\t$smtp ||= Net::SMTP->new( $smtp_server );\n-\t\t$smtp->mail( $from ) or die $smtp->message;\n+\t\t$smtp->mail( $envelope_sender ) or die $smtp->message;\n \t\t$smtp->to( @recipients ) or die $smtp->message;\n \t\t$smtp->data or die $smtp->message;\n \t\t$smtp->datasend(\"$header\\n$message\") or die $smtp->message;\n@@ -489,17 +497,15 @@ X-Mailer: git-send-email $gitversion\n \t} else {\n \t\tprint \"OK. Log says:\\nDate: $date\\n\";\n \t\tif ($smtp) {\n-\t\t\tprint \"Server: $smtp_server\\n\";\n+\t\t\tprint \"SMTP Server: $smtp_server\\n\";\n+\t\t\tprint \"SMTP MAIL FROM: $envelope_sender\\n\";\n+\t\t\tprint \"SMTP RCPT TO: \".join(', ',@recipients).\"\\n\";\n \t\t} else {\n \t\t\tprint \"Sendmail: $smtp_server\\n\";\n-\t\t\tmy $s = \"\";\n-\t\t\tforeach my $a (@sendmail_args) {\n-\t\t\t\t$s .= \" \\'\".$a.\"\\'\";\n-\t\t\t}\n-\t\t\tprint \"Args:$s\\n\";\n+\t\t\tprint \"Args: '\".join(\"' '\",@sendmail_args).\"'\\n\";\n \t\t}\n \t\tprint \"From: $from\\nSubject: $subject\\nCc: $cc\\nTo: $to\\n\\n\";\n-\t\tif ($smtp) {\n+\t\tif ($smtp and not $dry_run) {\n \t\t\tprint \"Result: \", $smtp->code, ' ',\n \t\t\t\t($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\n \t\t} else {\n@@ -616,7 +622,7 @@ sub cleanup_compose_files() {\n \n }\n \n-$smtp->quit if $smtp;\n+$smtp->quit if ($smtp and not $dry_run);\n \n sub unique_email_list(@) {\n \tmy %seen;\n-- \n1.5.1\n"},{"id":"39037","messageId":"20070410220610.GE18541@curie-int.orbis-terrarum.net","threadId":"7600","inReplyTo":"11762425341841-git-send-email-robbat2@gentoo.org","subject":"Re: [PATCH] Add sendmail -f support to git-send-email.","fromName":"Robin H. Johnson","fromEmail":"robbat2@orbis-terrarum.net","sentAt":"2007-04-10T22:06:10Z","receivedAt":"2007-04-10T22:06:10Z","isPatch":true,"sender":{"key":"robbat2@orbis-terrarum.net","avatar":"https://gravatar.com/avatar/6f1181f41d80f036d5db109308d31255fd0ab833373bb849e7b773453cb306bb?d=mp&s=160"},"body":"Weird mail header here:\n\"Cc: junkio@cox.net, Robin@orbis-terrarum.net, H.Johnson@orbis-terrarum.net, robbat2@gentoo.org\"\n\nLooks like git-send-email didn't put the quotation marks around the CC\naddress, so my MTA broke it up (and tried to expand each part locally).\n\n-- \nRobin Hugh Johnson\nE-Mail     : robbat2@orbis-terrarum.net\nHome Page  : http://www.orbis-terrarum.net/?l=people.robbat2\nICQ#       : 30269588 or 41961639\nGnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85\n"},{"id":"39066","messageId":"20070410223826.GH2813@planck.djpig.de","threadId":"7600","inReplyTo":"11762425341841-git-send-email-robbat2@gentoo.org","subject":"Re: [PATCH] Add sendmail -f support to git-send-email.","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-04-10T22:38:27Z","receivedAt":"2007-04-10T22:38:27Z","isPatch":true,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"On Tue, Apr 10, 2007 at 03:02:13PM -0700, Robin H. Johnson wrote:\n> Some mailing lists use the envelope sender instead of the actual from address,\n> and this can be broken in git-send-email. This patch sets the -f argument to\n> the sendmail binary, using the address of the patch author.\n\nAt least some MTAs (exim is the one I know for sure) can restrict -f\nusage to some users and deny it for others. Don't know how much this\nwould really be a problem, but using -f unconditionally might be a bad\nidea none-the-less.\n\nGruesse,\n-- \nFrank Lichtenheld <frank@lichtenheld.de>\nwww: http://www.djpig.de/\n"},{"id":"39070","messageId":"20070410224213.GF18541@curie-int.orbis-terrarum.net","threadId":"7600","inReplyTo":"20070410223826.GH2813@planck.djpig.de","subject":"Re: [PATCH] Add sendmail -f support to git-send-email.","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2007-04-10T22:42:14Z","receivedAt":"2007-04-10T22:42:14Z","isPatch":true,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"On Wed, Apr 11, 2007 at 12:38:27AM +0200, Frank Lichtenheld wrote:\n> At least some MTAs (exim is the one I know for sure) can restrict -f\n> usage to some users and deny it for others. Don't know how much this\n> would really be a problem, but using -f unconditionally might be a bad\n> idea none-the-less.\nIn those cases, the sendmail binary should fail gracefully, and then you\nknow that at least your email isn't lost into the ether.\n\n-- \nRobin Hugh Johnson\nGentoo Linux Developer & Council Member\nE-Mail     : robbat2@gentoo.org\nGnuPG FP   : 11AC BA4F 4778 E3F6 E4ED  F38E B27B 944E 3488 4E85\n"},{"id":"39072","messageId":"7v6483u95i.fsf@assigned-by-dhcp.cox.net","threadId":"7600","inReplyTo":"20070410223826.GH2813@planck.djpig.de","subject":"Re: [PATCH] Add sendmail -f support to git-send-email.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-10T23:00:57Z","receivedAt":"2007-04-10T23:00:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Frank Lichtenheld <frank@lichtenheld.de> writes:\n\n> On Tue, Apr 10, 2007 at 03:02:13PM -0700, Robin H. Johnson wrote:\n>> Some mailing lists use the envelope sender instead of the actual from address,\n>> and this can be broken in git-send-email. This patch sets the -f argument to\n>> the sendmail binary, using the address of the patch author.\n>\n> At least some MTAs (exim is the one I know for sure) can restrict -f\n> usage to some users and deny it for others. Don't know how much this\n> would really be a problem, but using -f unconditionally might be a bad\n> idea none-the-less.\n\nI thought I saw the '-f' patch somewhere on the list in the last\nseveral weeks and there was a discussion on this topic that\nfollowed the patch.  Am I hallucinating, or was it not applied\nbecause there were some issues?\n"},{"id":"39080","messageId":"20070411003818.GI2813@planck.djpig.de","threadId":"7600","inReplyTo":"7v6483u95i.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add sendmail -f support to git-send-email.","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-04-11T00:38:18Z","receivedAt":"2007-04-11T00:38:18Z","isPatch":true,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"On Tue, Apr 10, 2007 at 04:00:57PM -0700, Junio C Hamano wrote:\n> Frank Lichtenheld <frank@lichtenheld.de> writes:\n> \n> > On Tue, Apr 10, 2007 at 03:02:13PM -0700, Robin H. Johnson wrote:\n> >> Some mailing lists use the envelope sender instead of the actual from address,\n> >> and this can be broken in git-send-email. This patch sets the -f argument to\n> >> the sendmail binary, using the address of the patch author.\n> >\n> > At least some MTAs (exim is the one I know for sure) can restrict -f\n> > usage to some users and deny it for others. Don't know how much this\n> > would really be a problem, but using -f unconditionally might be a bad\n> > idea none-the-less.\n> \n> I thought I saw the '-f' patch somewhere on the list in the last\n> several weeks and there was a discussion on this topic that\n> followed the patch.  Am I hallucinating, or was it not applied\n> because there were some issues?\n\nCan't find anything in the archives. So either I completly suck\nat searching, or it is at least several months old, or you\nare hallucinating :)\n\nGruesse,\n-- \nFrank Lichtenheld <frank@lichtenheld.de>\nwww: http://www.djpig.de/\n"},{"id":"39085","messageId":"7vejmrqyj6.fsf@assigned-by-dhcp.cox.net","threadId":"7600","inReplyTo":"20070411003818.GI2813@planck.djpig.de","subject":"Re: [PATCH] Add sendmail -f support to git-send-email.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-11T05:18:37Z","receivedAt":"2007-04-11T05:18:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Frank Lichtenheld <frank@lichtenheld.de> writes:\n\n>> I thought I saw the '-f' patch somewhere on the list in the last\n>> several weeks and there was a discussion on this topic that\n>> followed the patch.  Am I hallucinating, or was it not applied\n>> because there were some issues?\n>\n> Can't find anything in the archives. So either I completly suck\n> at searching, or it is at least several months old, or you\n> are hallucinating :)\n\nIt was the thread about update-hook that sends e-mail; the\ndiscussion ends here:\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/42927/focus=42996\n\nThe patch was from Jim Meyering that made the script to\nunconditionally pass -f '$envelope_sender'; it was not applied\nbecause the whole e-mail sending business was removed from the\nupdate hook.\n\nWe seem to do a \"-f '$envelope_sender'\" in the example 'post-receive'\nhook only when the configuration tells it to, so probably it is\na good idea to follow suit in this program.\n"},{"id":"39107","messageId":"461CA307.9000507@etek.chalmers.se","threadId":"7600","inReplyTo":"20070411003818.GI2813@planck.djpig.de","subject":"Re: [PATCH] Add sendmail -f support to git-send-email.","fromName":"Lukas Sandström","fromEmail":"lukass@etek.chalmers.se","sentAt":"2007-04-11T08:57:43Z","receivedAt":"2007-04-11T08:57:43Z","isPatch":true,"sender":{"key":"luksan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/152281?v=4"},"body":"Frank Lichtenheld wrote:\n> On Tue, Apr 10, 2007 at 04:00:57PM -0700, Junio C Hamano wrote:\n>> Frank Lichtenheld <frank@lichtenheld.de> writes:\n>> I thought I saw the '-f' patch somewhere on the list in the last\n>> several weeks and there was a discussion on this topic that\n>> followed the patch.  Am I hallucinating, or was it not applied\n>> because there were some issues?\n> \n> Can't find anything in the archives. So either I completly suck\n> at searching, or it is at least several months old, or you\n> are hallucinating :)\n> \n> Gruesse,\n\nSe the thread starting with the mail\nMessage-ID: <874poc88ix.fsf@rho.meyering.net>\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/42927/\n\nThe discussion was about hooks--update, not git-send-mail.\n\n/Lukas\n"}]}