@@ -32,6 +32,13 @@ class Message {
3232 */
3333 public $ uid = '' ;
3434
35+ /**
36+ * Fetch body options
37+ *
38+ * @var string
39+ */
40+ public $ fetch_options = null ;
41+
3542 /**
3643 * @var int $msglist
3744 */
@@ -118,11 +125,13 @@ class Message {
118125 * @param $uid
119126 * @param $msglist
120127 * @param \Webklex\IMAP\Client $client
128+ * @param $fetch_options
121129 */
122- public function __construct ($ uid , $ msglist , Client $ client ) {
130+ public function __construct ($ uid , $ msglist , Client $ client, $ fetch_options = null ) {
123131 $ this ->uid = $ uid ;
124132 $ this ->msglist = $ msglist ;
125133 $ this ->client = $ client ;
134+ $ this ->fetch_options = ($ fetch_options ) ? $ fetch_options : FT_UID ;
126135
127136 $ this ->parseHeader ();
128137 $ this ->parseBody ();
@@ -314,7 +323,7 @@ private function fetchStructure($structure, $partNumber = null) {
314323
315324 $ encoding = $ this ->getEncoding ($ structure );
316325
317- $ content = imap_fetchbody ($ this ->client ->connection , $ this ->uid , $ partNumber , FT_UID );
326+ $ content = imap_fetchbody ($ this ->client ->connection , $ this ->uid , $ partNumber , $ this -> fetch_options );
318327 $ content = $ this ->decodeString ($ content , $ structure ->encoding );
319328 $ content = $ this ->convertEncoding ($ content , $ encoding );
320329
@@ -331,7 +340,7 @@ private function fetchStructure($structure, $partNumber = null) {
331340
332341 $ encoding = $ this ->getEncoding ($ structure );
333342
334- $ content = imap_fetchbody ($ this ->client ->connection , $ this ->uid , $ partNumber , FT_UID );
343+ $ content = imap_fetchbody ($ this ->client ->connection , $ this ->uid , $ partNumber , $ this -> fetch_options );
335344 $ content = $ this ->decodeString ($ content , $ structure ->encoding );
336345 $ content = $ this ->convertEncoding ($ content , $ encoding );
337346
@@ -374,7 +383,7 @@ private function fetchStructure($structure, $partNumber = null) {
374383 break ;
375384 }
376385
377- $ content = imap_fetchbody ($ this ->client ->connection , $ this ->uid , ($ partNumber ) ? $ partNumber : 1 , FT_UID );
386+ $ content = imap_fetchbody ($ this ->client ->connection , $ this ->uid , ($ partNumber ) ? $ partNumber : 1 , $ this -> fetch_options );
378387
379388 $ attachment = new \stdClass ;
380389 $ attachment ->type = $ type ;
0 commit comments