X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-send-email.perl;h=eb876f88ddec315991c2634a976eca8e5b99a1ba;hb=59d10247e444b752a993cf4aa2e0665bc633d32f;hp=d6b15480dc1e211f0653ff54963889464dad3573;hpb=e8760cde01299817daae26c9ad074b776bbd8f88;p=git.git diff --git a/git-send-email.perl b/git-send-email.perl index d6b15480d..eb876f88d 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -77,6 +77,10 @@ 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. + + --envelope-sender Specify the envelope sender used to send the emails. + EOT exit(1); } @@ -137,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>'; @@ -149,8 +154,8 @@ if ($@) { $term = new FakeTerm "$@: going non-interactive"; } -my $def_chain = $repo->config_boolean('sendemail.chainreplyto'); -if ($def_chain and $def_chain eq 'false') { +my $def_chain = $repo->config_bool('sendemail.chainreplyto'); +if (defined $def_chain and not $def_chain) { $chain_reply_to = 0; } @@ -175,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) { @@ -206,7 +212,7 @@ my $aliasfiletype = $repo->config('sendemail.aliasfiletype'); my %parse_alias = ( # multiline formats can be supported in the future mutt => sub { my $fh = shift; while (<$fh>) { - if (/^alias\s+(\S+)\s+(.*)$/) { + if (/^\s*alias\s+(\S+)\s+(.*)$/) { my ($alias, $addr) = ($1, $2); $addr =~ s/#.*$//; # mutt allows # comments # commas delimit multiple addresses @@ -268,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); @@ -377,7 +384,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; @@ -418,7 +425,6 @@ sub make_message_id -$cc = ""; $time = time - scalar $#files; sub unquote_rfc2047 { @@ -430,26 +436,37 @@ 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+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; @@ -489,13 +511,15 @@ 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"; - if ($smtp) { + print (($dry_run ? "Dry-" : "")."OK. Log says:\nDate: $date\n"); + if ($smtp_server !~ m#^/#) { print "Server: $smtp_server\n"; + print "MAIL FROM:<$raw_from>\n"; + print "RCPT TO:".join(',',(map { "<$_>" } @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) { @@ -590,7 +614,6 @@ foreach my $t (@files) { $message = "From: $author_not_sender\n\n$message"; } - $cc = join(", ", unique_email_list(@cc)); send_message();