@@ -438,34 +438,32 @@ private function fetchStructure($structure) {
438
438
*/
439
439
private function fetchPart (Part $ part ) {
440
440
441
- if ($ part ->type == IMAP ::MESSAGE_TYPE_TEXT && ($ part ->ifdisposition == 0 || (empty ($ part ->disposition ) || !in_array (strtolower ($ part ->disposition ), ['attachment ' , 'inline ' ])) ) ) {
442
-
443
- if ( in_array (($ subtype = strtolower ($ part ->subtype )), ["plain " , "csv " , "html " ]) && $ part ->filename == null && $ part ->name == null ) {
444
- $ encoding = $ this ->getEncoding ($ part );
445
-
446
- $ content = $ this ->decodeString ($ part ->content , $ part ->encoding );
447
-
448
- // We don't need to do convertEncoding() if charset is ASCII (us-ascii):
449
- // ASCII is a subset of UTF-8, so all ASCII files are already UTF-8 encoded
450
- // https://stackoverflow.com/a/11303410
451
- //
452
- // us-ascii is the same as ASCII:
453
- // ASCII is the traditional name for the encoding system; the Internet Assigned Numbers Authority (IANA)
454
- // prefers the updated name US-ASCII, which clarifies that this system was developed in the US and
455
- // based on the typographical symbols predominantly in use there.
456
- // https://en.wikipedia.org/wiki/ASCII
457
- //
458
- // convertEncoding() function basically means convertToUtf8(), so when we convert ASCII string into UTF-8 it gets broken.
459
- if ($ encoding != 'us-ascii ' ) {
460
- $ content = $ this ->convertEncoding ($ content , $ encoding );
461
- }
462
-
463
- $ this ->bodies [$ subtype == "plain " ? "text " : $ subtype ] = $ content ;
464
- } else {
465
- $ this ->fetchAttachment ($ part );
466
- }
467
- } else {
441
+ if ($ part ->isAttachment ()) {
468
442
$ this ->fetchAttachment ($ part );
443
+ }else {
444
+ $ encoding = $ this ->getEncoding ($ part );
445
+
446
+ $ content = $ this ->decodeString ($ part ->content , $ part ->encoding );
447
+
448
+ // We don't need to do convertEncoding() if charset is ASCII (us-ascii):
449
+ // ASCII is a subset of UTF-8, so all ASCII files are already UTF-8 encoded
450
+ // https://stackoverflow.com/a/11303410
451
+ //
452
+ // us-ascii is the same as ASCII:
453
+ // ASCII is the traditional name for the encoding system; the Internet Assigned Numbers Authority (IANA)
454
+ // prefers the updated name US-ASCII, which clarifies that this system was developed in the US and
455
+ // based on the typographical symbols predominantly in use there.
456
+ // https://en.wikipedia.org/wiki/ASCII
457
+ //
458
+ // convertEncoding() function basically means convertToUtf8(), so when we convert ASCII string into UTF-8 it gets broken.
459
+ if ($ encoding != 'us-ascii ' ) {
460
+ $ content = $ this ->convertEncoding ($ content , $ encoding );
461
+ }
462
+
463
+ $ subtype = strtolower ($ part ->subtype );
464
+ $ subtype = $ subtype == "plain " || $ subtype == "" ? "text " : $ subtype ;
465
+
466
+ $ this ->bodies [$ subtype ] = $ content ;
469
467
}
470
468
}
471
469
0 commit comments