File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed
Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -314,16 +314,26 @@ public function getBody($mailId, array $data)
314314 if ($ dataMessage === FALSE ) {
315315 throw new DriverException ("Cannot read given message part - " . error_get_last ()["message " ]);
316316 }
317- $ encoding = $ part ['encoding ' ];
318- if ($ encoding === ImapStructure::ENCODING_BASE64 ) {
319- $ dataMessage = base64_decode ($ dataMessage );
320- } else if ($ encoding === ImapStructure::ENCODING_QUOTED_PRINTABLE ) {
321- $ dataMessage = quoted_printable_decode ($ dataMessage );
322- }
323317
324- // todo: other encodings?
318+ // when there is no encoding of mime part available
319+ if (!isset ($ part ['encoding ' ])) {
320+ $ decodedMessage = $ dataMessage ;
321+
322+ } elseif ($ part ['encoding ' ] === ImapStructure::ENCODING_BASE64 ) {
323+ $ decodedMessage = base64_decode ($ dataMessage );
324+ if ($ decodedMessage === FALSE ) {
325+ throw new DriverException ('Malformed mime-part: cannot decode base64 mime-part ' );
326+ }
327+
328+ } elseif ($ part ['encoding ' ] === ImapStructure::ENCODING_QUOTED_PRINTABLE ) {
329+ $ decodedMessage = quoted_printable_decode ($ dataMessage );
330+
331+ } else {
332+ throw new DriverException ("Mime-part reading error: unknown encoding ( {$ part ['encoding ' ]}) " );
333+
334+ }
325335
326- $ body [] = $ dataMessage ;
336+ $ body [] = $ decodedMessage ;
327337 }
328338 return implode ('\n\n ' , $ body );
329339 }
You can’t perform that action at this time.
0 commit comments