From 356a23e8a93d5dc755ae95425546f814789a9df9 Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 27 Feb 2024 22:26:58 +0200 Subject: [PATCH] * Mail: display messages containing just a PDF (and no body part) --- api/src/Mail.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/api/src/Mail.php b/api/src/Mail.php index 320d33bd1a..751d10157a 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -4963,6 +4963,14 @@ class Mail //_debug_array($_structure->getMimeId()); exit; } + // if message is just a pdf, return it to browser to display + if ($_structure->getType() === 'application/pdf') + { + header('Content-Type: application/pdf'); + echo $this->getAttachment($_uid, $_partID ?? '1', 0, true, $_folder)->getContents(); + exit(); + } + switch($_structure->getPrimaryType()) { case 'application': @@ -6194,7 +6202,9 @@ class Mail // we need to set content on structure to decode transfer encoding $part->setContents( $this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary), - array('encoding' => (!$fetchAsBinary&&!$encoding?'8bit':$encoding))); + // some mailer e.g. "SAP NetWeaver 750" set not transfer-encoding for pdf --> use base64 when fetching as binary + array('encoding' => $fetchAsBinary && $part->getType() === 'application/pdf' ? 'base64' : + (!$fetchAsBinary&&!$encoding?'8bit':$encoding))); return $part; }