@@ -143,7 +143,7 @@ sub format_2822_time {
143143sub cleanup_compose_files ();
144144
145145# Variables we fill in automatically, or via prompting:
146- my (@to ,$no_to ,@cc ,$no_cc ,@initial_cc ,@bcclist ,$no_bcc ,@xh ,
146+ my (@to ,$no_to ,@initial_to , @ cc ,$no_cc ,@initial_cc ,@bcclist ,$no_bcc ,@xh ,
147147 $initial_reply_to ,$initial_subject ,@files ,
148148 $author ,$sender ,$smtp_authpass ,$annotate ,$compose ,$time );
149149
@@ -222,7 +222,7 @@ sub do_edit {
222222 " smtpuser" => \$smtp_authuser ,
223223 " smtppass" => \$smtp_authpass ,
224224 " smtpdomain" => \$smtp_domain ,
225- " to" => \@to ,
225+ " to" => \@initial_to ,
226226 " tocmd" => \$to_cmd ,
227227 " cc" => \@initial_cc ,
228228 " cccmd" => \$cc_cmd ,
@@ -281,7 +281,7 @@ sub signal_handler {
281281my $rc = GetOptions(" sender|from=s" => \$sender ,
282282 " in-reply-to=s" => \$initial_reply_to ,
283283 " subject=s" => \$initial_subject ,
284- " to=s" => \@to ,
284+ " to=s" => \@initial_to ,
285285 " to-cmd=s" => \$to_cmd ,
286286 " no-to" => \$no_to ,
287287 " cc=s" => \@initial_cc ,
@@ -422,7 +422,7 @@ sub read_config {
422422
423423# Verify the user input
424424
425- foreach my $entry (@to ) {
425+ foreach my $entry (@initial_to ) {
426426 die " Comma in --to entry: $entry '\n " unless $entry !~ m / ,/ ;
427427}
428428
734734 $prompting ++;
735735}
736736
737- if (!@to && !defined $to_cmd ) {
737+ if (!@initial_to && !defined $to_cmd ) {
738738 my $to = ask(" Who should the emails be sent to? " );
739- push @to , parse_address_line($to ) if defined $to ; # sanitized/validated later
739+ push @initial_to , parse_address_line($to ) if defined $to ; # sanitized/validated later
740740 $prompting ++;
741741}
742742
@@ -754,8 +754,8 @@ sub expand_one_alias {
754754 return $aliases {$alias } ? expand_aliases(@{$aliases {$alias }}) : $alias ;
755755}
756756
757- @to = expand_aliases(@to );
758- @to = (map { sanitize_address($_ ) } @to );
757+ @initial_to = expand_aliases(@initial_to );
758+ @initial_to = (map { sanitize_address($_ ) } @initial_to );
759759@initial_cc = expand_aliases(@initial_cc );
760760@bcclist = expand_aliases(@bcclist );
761761
@@ -1161,6 +1161,7 @@ sub send_message {
11611161 my $author_encoding ;
11621162 my $has_content_type ;
11631163 my $body_encoding ;
1164+ @to = ();
11641165 @cc = ();
11651166 @xh = ();
11661167 my $input_format = undef ;
@@ -1201,6 +1202,13 @@ sub send_message {
12011202 $1 , $_ ) unless $quiet ;
12021203 push @cc , $1 ;
12031204 }
1205+ elsif (/ ^To:\s +(.*)$ / ) {
1206+ foreach my $addr (parse_address_line($1 )) {
1207+ printf (" (mbox) Adding to: %s from line '%s '\n " ,
1208+ $addr , $_ ) unless $quiet ;
1209+ push @to , sanitize_address($addr );
1210+ }
1211+ }
12041212 elsif (/ ^Cc:\s +(.*)$ / ) {
12051213 foreach my $addr (parse_address_line($1 )) {
12061214 if (unquote_rfc2047($addr ) eq $sender ) {
@@ -1307,6 +1315,7 @@ sub send_message {
13071315 ($confirm =~ / ^(?:auto|compose)$ / && $compose && $message_num == 1));
13081316 $needs_confirm = " inform" if ($needs_confirm && $confirm_unconfigured && @cc );
13091317
1318+ @to = (@initial_to , @to );
13101319 @cc = (@initial_cc , @cc );
13111320
13121321 my $message_was_sent = send_message();
0 commit comments