@@ -607,10 +607,7 @@ impl MimeFactory {
607
607
|| to. len( ) + past_members. len( ) == self . member_timestamps. len( )
608
608
) ;
609
609
if to. is_empty ( ) {
610
- to. push ( Address :: new_group (
611
- Some ( "hidden-recipients" . to_string ( ) ) ,
612
- Vec :: new ( ) ,
613
- ) ) ;
610
+ to. push ( hidden_recipients ( ) ) ;
614
611
}
615
612
616
613
// Start with Internet Message Format headers in the order of the standard example
@@ -888,21 +885,23 @@ impl MimeFactory {
888
885
} else if header_name == "to" {
889
886
protected_headers. push ( header. clone ( ) ) ;
890
887
if is_encrypted {
888
+ let mut to_without_names = to
889
+ . clone ( )
890
+ . into_iter ( )
891
+ . filter_map ( |header| match header {
892
+ Address :: Address ( mb) => Some ( Address :: Address ( EmailAddress {
893
+ name : None ,
894
+ email : mb. email ,
895
+ } ) ) ,
896
+ _ => None ,
897
+ } )
898
+ . collect :: < Vec < _ > > ( ) ;
899
+ if to_without_names. is_empty ( ) {
900
+ to_without_names. push ( hidden_recipients ( ) ) ;
901
+ }
891
902
unprotected_headers. push ( (
892
903
original_header_name,
893
- Address :: new_list (
894
- to. clone ( )
895
- . into_iter ( )
896
- . filter_map ( |header| match header {
897
- Address :: Address ( mb) => Some ( Address :: Address ( EmailAddress {
898
- name : None ,
899
- email : mb. email ,
900
- } ) ) ,
901
- _ => None ,
902
- } )
903
- . collect :: < Vec < _ > > ( ) ,
904
- )
905
- . into ( ) ,
904
+ Address :: new_list ( to_without_names) . into ( ) ,
906
905
) ) ;
907
906
} else {
908
907
unprotected_headers. push ( header. clone ( ) ) ;
@@ -1633,6 +1632,10 @@ impl MimeFactory {
1633
1632
}
1634
1633
}
1635
1634
1635
+ fn hidden_recipients ( ) -> Address < ' static > {
1636
+ Address :: new_group ( Some ( "hidden-recipients" . to_string ( ) ) , Vec :: new ( ) )
1637
+ }
1638
+
1636
1639
async fn build_body_file ( context : & Context , msg : & Message ) -> Result < MimePart < ' static > > {
1637
1640
let file_name = msg. get_filename ( ) . context ( "msg has no file" ) ?;
1638
1641
let suffix = Path :: new ( & file_name)
0 commit comments