]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-send-email.perl
git-help -w: do not require to be in git repository
[git.git] / git-send-email.perl
index 47afc56915c8ea6e27ae34f3f3c9baa9075536a8..c0e1dd348c1f62029bb99b16cae290d2e4a77217 100755 (executable)
@@ -145,6 +145,7 @@ sub format_2822_time {
 
 my $have_email_valid = eval { require Email::Valid; 1 };
 my $smtp;
+my $auth;
 
 sub unique_email_list(@);
 sub cleanup_compose_files();
@@ -366,10 +367,11 @@ if ($thread && !defined $initial_reply_to && $prompting) {
        } while (!defined $_);
 
        $initial_reply_to = $_;
-       $initial_reply_to =~ s/^\s+<?/</;
-       $initial_reply_to =~ s/>?\s+$/>/;
 }
 
+$initial_reply_to =~ s/^\s*<?/</;
+$initial_reply_to =~ s/>?\s*$/>/;
+
 if (!defined $smtp_server) {
        foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {
                if (-x $_) {
@@ -557,7 +559,11 @@ sub sanitize_address
 sub send_message
 {
        my @recipients = unique_email_list(@to);
-       @cc = (map { sanitize_address($_) } @cc);
+       @cc = (grep { my $cc = extract_valid_address($_);
+                     not grep { $cc eq $_ } @recipients
+                   }
+              map { sanitize_address($_) }
+              @cc);
        my $to = join (",\n\t", @recipients);
        @recipients = unique_email_list(@recipients,@cc,@bcclist);
        @recipients = (map { extract_valid_address($_) } @recipients);
@@ -631,7 +637,7 @@ X-Mailer: git-send-email $gitversion
                }
 
                if ((defined $smtp_authuser) && (defined $smtp_authpass)) {
-                       $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
+                       $auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
                }
                $smtp->mail( $raw_from ) or die $smtp->message;
                $smtp->to( @recipients ) or die $smtp->message;
@@ -781,7 +787,8 @@ foreach my $t (@files) {
                        else {
                                push @xh,
                                  'MIME-Version: 1.0',
-                                 "Content-Type: text/plain; charset=$author_encoding";
+                                 "Content-Type: text/plain; charset=$author_encoding",
+                                 'Content-Transfer-Encoding: 8bit';
                        }
                }
        }