From 238cc6352eabe3f87f13093bc4015162bf424509 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 25 Apr 2007 19:37:15 -0700 Subject: Document --dry-run parameter to send-email. Looks like --dry-run was added to the code, but never to the --help output. Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 1278fcba4..5e38a97cb 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -77,6 +77,8 @@ Options: --quiet Make git-send-email less verbose. One line per email should be all that is output. + --dry-run Do everything except actually send the emails. + EOT exit(1); } -- cgit v1.2.1 From 71c7da94218fbe36e64a326825ff30ef811b2a88 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 25 Apr 2007 19:37:16 -0700 Subject: Prefix Dry- to the message status to denote dry-runs. While doing testing, it's useful to see that a dry run was actually done, instead of a real one. Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- git-send-email.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 5e38a97cb..50d45fe00 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -488,9 +488,9 @@ X-Mailer: git-send-email $gitversion $smtp->ok or die "Failed to send $subject\n".$smtp->message; } if ($quiet) { - printf "Sent %s\n", $subject; + printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject); } else { - print "OK. Log says:\nDate: $date\n"; + print (($dry_run ? "Dry-" : "")."OK. Log says:\nDate: $date\n"); if ($smtp) { print "Server: $smtp_server\n"; } else { -- cgit v1.2.1 From 8e3d436b0b5148bac11259bac55621e285eeb6c4 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 25 Apr 2007 19:37:17 -0700 Subject: Debugging cleanup improvements The debug output is much more helpful if it has the parameters that were used. Pull the sendmail parameters into a seperate array for that, and also include similar data during the Net::SMTP case. Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- git-send-email.perl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 50d45fe00..36795c8bd 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -465,15 +465,15 @@ X-Mailer: git-send-email $gitversion $header .= join("\n", @xh) . "\n"; } + my @sendmail_parameters = ('-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_parameters) or die $!; } print $sm "$header\n$message"; close $sm or die $?; @@ -493,8 +493,10 @@ X-Mailer: git-send-email $gitversion print (($dry_run ? "Dry-" : "")."OK. Log says:\nDate: $date\n"); if ($smtp) { print "Server: $smtp_server\n"; + print "MAIL FROM: $from\n"; + print "RCPT TO: ".join(',',@recipients)."\n"; } else { - print "Sendmail: $smtp_server\n"; + print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n"; } print "From: $from\nSubject: $subject\nCc: $cc\nTo: $to\n\n"; if ($smtp) { -- cgit v1.2.1 From af068d274245be9aedc58e6835c2e43329639974 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 25 Apr 2007 19:37:18 -0700 Subject: Change the scope of the $cc variable as it is not needed outside of send_message. $cc is only used inside the send_message scope, so lets clean it out of the global scope. Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- git-send-email.perl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 36795c8bd..ad83009e2 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -379,7 +379,7 @@ if (@files) { } # Variables we set as part of the loop over files -our ($message_id, $cc, %mail, $subject, $reply_to, $references, $message); +our ($message_id, %mail, $subject, $reply_to, $references, $message); sub extract_valid_address { my $address = shift; @@ -420,7 +420,6 @@ sub make_message_id -$cc = ""; $time = time - scalar $#files; sub unquote_rfc2047 { @@ -443,7 +442,8 @@ sub send_message $gitversion = Git::version(); } - my ($author_name) = ($from =~ /^(.*?)\s+ Date: Wed, 25 Apr 2007 19:37:19 -0700 Subject: Perform correct quoting of recipient names. Always perform quoting of the recipient names if they contain periods, previously only the author's address was treated this way. This stops sendmail binaries from exploding the name into bad addresses. Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- git-send-email.perl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index ad83009e2..e4fe8965b 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -431,9 +431,22 @@ sub unquote_rfc2047 { return "$_"; } +# If an address contains a . in the name portion, the name must be quoted. +sub sanitize_address_rfc822 +{ + my ($recipient) = @_; + my ($recipient_name) = ($recipient =~ /^(.*?)\s+ Date: Wed, 25 Apr 2007 19:37:20 -0700 Subject: Validate @recipients before using it for sendmail and Net::SMTP. Ensure that @recipients is only raw addresses when it is handed to the sendmail binary OR Net::SMTP, otherwise BCC cases might get an extra <, or wierd stuff might be passed to the exec. Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- git-send-email.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index e4fe8965b..b60229290 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -449,6 +449,7 @@ sub send_message @cc = (map { sanitize_address_rfc822($_) } @cc); my $to = join (",\n\t", @recipients); @recipients = unique_email_list(@recipients,@cc,@bcclist); + @recipients = (map { extract_valid_address($_) } @recipients); my $date = format_2822_time($time++); my $gitversion = '@@GIT_VERSION@@'; if ($gitversion =~ m/..GIT_VERSION../) { @@ -474,7 +475,7 @@ X-Mailer: git-send-email $gitversion $header .= join("\n", @xh) . "\n"; } - my @sendmail_parameters = ('-i', map { extract_valid_address($_) } @recipients); + my @sendmail_parameters = ('-i', @recipients); if ($dry_run) { # We don't want to send the email. -- cgit v1.2.1 From 2b69bfc23d89d2ec5507bc6906b533e8429b313d Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 25 Apr 2007 19:37:21 -0700 Subject: Ensure clean addresses are always used with Net::SMTP Always pass in clean addresses to Net::SMTP for the MAIL FROM, and use them on the SMTP non-quiet output as well. Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- git-send-email.perl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index b60229290..35c4722a1 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -476,6 +476,7 @@ X-Mailer: git-send-email $gitversion } my @sendmail_parameters = ('-i', @recipients); + my $raw_from = extract_valid_address($from); if ($dry_run) { # We don't want to send the email. @@ -490,7 +491,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( $raw_from ) 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; @@ -501,10 +502,10 @@ X-Mailer: git-send-email $gitversion printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject); } else { print (($dry_run ? "Dry-" : "")."OK. Log says:\nDate: $date\n"); - if ($smtp) { + if ($smtp_server !~ m#^/#) { print "Server: $smtp_server\n"; - print "MAIL FROM: $from\n"; - print "RCPT TO: ".join(',',@recipients)."\n"; + print "MAIL FROM:<$raw_from>\n"; + print "RCPT TO:".join(',',(map { "<$_>" } @recipients))."\n"; } else { print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n"; } -- cgit v1.2.1 From f073a592d6400b3aa653ce02943535bf917078b5 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 25 Apr 2007 19:37:22 -0700 Subject: Allow users to optionally specify their envelope sender. If your normal user is not the same user you are subscribed to a list with, then the default envelope sender used will cause your messages to bounce or silently vanish into the ether. This patch provides an optional parameter to set the envelope sender. To use it with the sendmail binary, you must have privileges to use the -f parameter! Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- git-send-email.perl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 35c4722a1..56c2936f2 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -79,6 +79,8 @@ Options: --dry-run Do everything except actually send the emails. + --envelope-sender Specify the envelope sender used to send the emails. + EOT exit(1); } @@ -139,6 +141,7 @@ my (@to,@cc,@initial_cc,@bcclist,@xh, my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc, $dry_run) = (1, 0, 0, 0, 0); my $smtp_server; +my $envelope_sender; # Example reply to: #$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>'; @@ -177,6 +180,7 @@ my $rc = GetOptions("from=s" => \$from, "suppress-from" => \$suppress_from, "no-signed-off-cc|no-signed-off-by-cc" => \$no_signed_off_cc, "dry-run" => \$dry_run, + "envelope-sender=s" => \$envelope_sender, ); unless ($rc) { @@ -476,7 +480,11 @@ X-Mailer: git-send-email $gitversion } my @sendmail_parameters = ('-i', @recipients); - my $raw_from = extract_valid_address($from); + my $raw_from = $from; + $raw_from = $envelope_sender if (defined $envelope_sender); + $raw_from = extract_valid_address($raw_from); + unshift (@sendmail_parameters, + '-f', $raw_from) if(defined $envelope_sender); if ($dry_run) { # We don't want to send the email. -- cgit v1.2.1 From bf7af1167411cbdd5ade7587a64b18d1b7b2ea69 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 25 Apr 2007 21:53:22 -0700 Subject: Sanitize @to recipients. We need to sanitize @to as well to ensure that names are properly quoted. Signed-off-by: Robin H. Johnson Signed-off-by: Junio C Hamano --- git-send-email.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 56c2936f2..12ced2888 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -274,6 +274,7 @@ sub expand_aliases { } @to = expand_aliases(@to); +@to = (map { sanitize_address_rfc822($_) } @to); @initial_cc = expand_aliases(@initial_cc); @bcclist = expand_aliases(@bcclist); -- cgit v1.2.1