@@ -70,6 +70,11 @@ class Message {
7070 */
7171 public $ msglist = 1 ;
7272
73+ /**
74+ * @var int $msgn
75+ */
76+ public $ msgn = null ;
77+
7378 /**
7479 * @var string $header
7580 */
@@ -169,8 +174,10 @@ public function __construct($uid, $msglist, Client $client, $fetch_options = nul
169174
170175 $ this ->msglist = $ msglist ;
171176 $ this ->client = $ client ;
172- $ this ->uid = ($ this ->fetch_options == FT_UID ) ? $ uid : imap_msgno ($ this ->client ->getConnection (), $ uid );
173-
177+
178+ $ this ->uid = ($ this ->fetch_options == FT_UID ) ? $ uid : $ uid ;
179+ $ this ->msgn = ($ this ->fetch_options == FT_UID ) ? imap_msgno ($ this ->client ->getConnection (), $ uid ) : $ uid ;
180+
174181 $ this ->parseHeader ();
175182
176183 if ($ this ->getFetchFlagsOption () === true ) {
@@ -267,7 +274,7 @@ public function getHTMLBody($replaceImages = false) {
267274 * @return void
268275 */
269276 private function parseHeader () {
270- $ this ->header = $ header = imap_fetchheader ($ this ->client ->getConnection (), $ this ->uid , $ this -> fetch_options );
277+ $ this ->header = $ header = imap_fetchheader ($ this ->client ->getConnection (), $ this ->uid , FT_UID );
271278 if ($ this ->header ) {
272279 $ header = imap_rfc822_parse_headers ($ this ->header );
273280 }
@@ -353,7 +360,7 @@ private function parseHeader() {
353360 * @return void
354361 */
355362 private function parseFlags () {
356- $ flags = imap_fetch_overview ($ this ->client ->getConnection (), $ this ->uid , $ this -> fetch_options );
363+ $ flags = imap_fetch_overview ($ this ->client ->getConnection (), $ this ->uid , FT_UID );
357364 if (is_array ($ flags ) && isset ($ flags [0 ])) {
358365 if (property_exists ($ flags [0 ], 'recent ' )) {
359366 $ this ->flags ->put ('recent ' , $ flags [0 ]->recent );
@@ -430,7 +437,7 @@ private function parseAddresses($list) {
430437 * @return $this
431438 */
432439 public function parseBody () {
433- $ structure = imap_fetchstructure ($ this ->client ->getConnection (), $ this ->uid , $ this -> fetch_options );
440+ $ structure = imap_fetchstructure ($ this ->client ->getConnection (), $ this ->uid , FT_UID );
434441
435442 if (property_exists ($ structure , 'parts ' )){
436443 $ parts = $ structure ->parts ;
@@ -469,7 +476,7 @@ private function fetchStructure($structure, $partNumber = null) {
469476
470477 $ encoding = $ this ->getEncoding ($ structure );
471478
472- $ content = imap_fetchbody ($ this ->client ->getConnection (), $ this ->uid , $ partNumber , $ this ->fetch_options );
479+ $ content = imap_fetchbody ($ this ->client ->getConnection (), $ this ->uid , $ partNumber , $ this ->fetch_options | FT_UID );
473480 $ content = $ this ->decodeString ($ content , $ structure ->encoding );
474481 $ content = $ this ->convertEncoding ($ content , $ encoding );
475482
@@ -488,7 +495,7 @@ private function fetchStructure($structure, $partNumber = null) {
488495
489496 $ encoding = $ this ->getEncoding ($ structure );
490497
491- $ content = imap_fetchbody ($ this ->client ->getConnection (), $ this ->uid , $ partNumber , $ this ->fetch_options );
498+ $ content = imap_fetchbody ($ this ->client ->getConnection (), $ this ->uid , $ partNumber , $ this ->fetch_options | FT_UID );
492499 $ content = $ this ->decodeString ($ content , $ structure ->encoding );
493500 $ content = $ this ->convertEncoding ($ content , $ encoding );
494501
@@ -682,7 +689,7 @@ public function getContainingFolder(Folder $folder = null) {
682689 // Try finding the message by uid in the current folder
683690 $ client = new Client ;
684691 $ client ->openFolder ($ folder );
685- $ uidMatches = imap_fetch_overview ($ client ->getConnection (), $ this ->uid , $ this -> fetch_options );
692+ $ uidMatches = imap_fetch_overview ($ client ->getConnection (), $ this ->uid , FT_UID );
686693 $ uidMatch = count ($ uidMatches )
687694 ? new Message ($ uidMatches [0 ]->uid , $ uidMatches [0 ]->msgno , $ client )
688695 : null ;
@@ -728,7 +735,7 @@ public function moveToFolder($mailbox = 'INBOX', $options = 0) {
728735 * @return bool
729736 */
730737 public function delete () {
731- $ status = imap_delete ($ this ->client ->getConnection (), $ this ->uid , $ this -> fetch_options );
738+ $ status = imap_delete ($ this ->client ->getConnection (), $ this ->uid , FT_UID );
732739 $ this ->client ->expunge ();
733740
734741 return $ status ;
@@ -740,7 +747,7 @@ public function delete() {
740747 * @return bool
741748 */
742749 public function restore () {
743- return imap_undelete ($ this ->client ->getConnection (), $ this ->message_no );
750+ return imap_undelete ($ this ->client ->getConnection (), $ this ->uid , FT_UID );
744751 }
745752
746753 /**
@@ -788,7 +795,7 @@ public function unsetFlag($flag) {
788795 */
789796 public function getRawBody () {
790797 if ($ this ->raw_body === null ) {
791- $ this ->raw_body = imap_fetchbody ($ this ->client ->getConnection (), $ this ->getMessageNo (), '' );
798+ $ this ->raw_body = imap_fetchbody ($ this ->client ->getConnection (), $ this ->getUid (), '' , $ this -> fetch_options | FT_UID );
792799 }
793800
794801 return $ this ->raw_body ;
0 commit comments