@@ -16,9 +16,9 @@ public function send(string $path, ...$params): void
1616 {
1717 $ html = $ this ->renderer ->render (view ($ path , ...$ params ));
1818
19- [$ header , $ body ] = explode (PHP_EOL , $ html , 2 );
19+ [$ headerString , $ body ] = explode (PHP_EOL , $ html , 2 );
2020
21- $ email = $ this ->makeEmail ($ header , $ body );
21+ $ email = $ this ->makeEmail ($ headerString , $ body );
2222
2323 $ this ->sendEmail ($ email );
2424 }
@@ -32,26 +32,17 @@ public function sendEmail(Email $email): void
3232 ld ($ email );
3333 }
3434
35- private function makeEmail (string $ header , string $ body ): Email
35+ private function makeEmail (string $ headerString , string $ body ): Email
3636 {
3737 $ parsedHeaders = [];
3838
39- $ headers = explode ( ' ; ' , $ header );
39+ preg_match_all ( ' /(?<header>\w+)="(?<value>.*?)"/ ' , $ headerString , $ headers );
4040
41- foreach ($ headers as $ header ) {
42- if (trim ($ header ) === '' ) {
43- continue ;
44- }
41+ foreach ($ headers [0 ] as $ i => $ line ) {
42+ $ header = $ headers ['header ' ][$ i ];
43+ $ value = $ headers ['value ' ][$ i ];
4544
46- [$ name , $ value ] = explode (': ' , $ header );
47-
48- $ value = trim ($ value );
49-
50- if ($ value === '' ) {
51- $ value = null ;
52- }
53-
54- $ parsedHeaders [trim ($ name )] = $ value ;
45+ $ parsedHeaders [$ header ] = $ value ;
5546 }
5647
5748 $ parsedHeaders ['attachments ' ] = explode (', ' , $ parsedHeaders ['attachments ' ] ?? '' );
0 commit comments