Add check for MIME encoded messages

As far as I understand MIME-encoded message can be broken down into parts based upon its contents. While most mail programs add the plain text part as the first part this is not true for all programs. In fact mail2deck couldn't import the body when processing certain plain text mails with attachments - because the plain text part wasn't  at position 1.1.

With this fix imap_fetchbody requests sub-part 1 of part 1 and, if it is empty/ non-existent, it requests part 1.
pull/21/head
kidhab 2022-04-11 20:19:59 +02:00 zatwierdzone przez GitHub
rodzic 82c869f6ba
commit f84b5c5f09
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -73,11 +73,15 @@ if ($emails)
$data->title = DECODE_SPECIAL_CHARACTERS ? mb_decode_mimeheader($overview->subject) : $overview->subject;
$data->type = "plain";
$data->order = -time();
$body = $inbox->fetchMessageBody($emails[$j], 1.1);
if ($body == "") {
$body = $inbox->fetchMessageBody($emails[$j], 1);
}
if(count($attachments)) {
$data->attachments = $attNames;
$description = DECODE_SPECIAL_CHARACTERS ? quoted_printable_decode($inbox->fetchMessageBody($emails[$j], 1.1)) : $inbox->fetchMessageBody($emails[$j], 1.1);
$description = DECODE_SPECIAL_CHARACTERS ? quoted_printable_decode($body) : $body;
} else {
$description = DECODE_SPECIAL_CHARACTERS ? quoted_printable_decode($inbox->fetchMessageBody($emails[$j], 1)) : $inbox->fetchMessageBody($emails[$j], 1);
$description = DECODE_SPECIAL_CHARACTERS ? quoted_printable_decode($body) : $body;
}
if($base64encode) {
$description = base64_decode($description);