@@ -47,6 +47,11 @@ class Message {
4747 */
4848 public $ msglist = 1 ;
4949
50+ /**
51+ * @var string $header
52+ */
53+ public $ header = null ;
54+
5055 /**
5156 * Message header components
5257 *
@@ -146,7 +151,7 @@ public function __construct($uid, $msglist, Client $client, $fetch_options = nul
146151 * @return bool
147152 */
148153 public function copy ($ mailbox , $ options = 0 ){
149- return imap_mail_copy ($ this ->client ->connection , $ this ->msglist , $ mailbox , $ options );
154+ return imap_mail_copy ($ this ->client ->getConnection () , $ this ->msglist , $ mailbox , $ options );
150155 }
151156
152157 /**
@@ -158,7 +163,7 @@ public function copy($mailbox, $options = 0){
158163 * @return bool
159164 */
160165 public function move ($ mailbox , $ options = 0 ){
161- return imap_mail_move ($ this ->client ->connection , $ this ->msglist , $ mailbox , $ options );
166+ return imap_mail_move ($ this ->client ->getConnection () , $ this ->msglist , $ mailbox , $ options );
162167 }
163168
164169 /**
@@ -222,9 +227,9 @@ public function getHTMLBody($replaceImages = false) {
222227 * @return void
223228 */
224229 private function parseHeader () {
225- $ header = imap_fetchheader ($ this ->client ->connection , $ this ->uid , $ this ->fetch_options );
226- if ($ header ) {
227- $ header = imap_rfc822_parse_headers ($ header );
230+ $ this -> header = $ header = imap_fetchheader ($ this ->client ->getConnection () , $ this ->uid , $ this ->fetch_options );
231+ if ($ this -> header ) {
232+ $ header = imap_rfc822_parse_headers ($ this -> header );
228233 }
229234
230235 if (property_exists ($ header , 'subject ' )) {
@@ -326,7 +331,7 @@ private function parseAddresses($list) {
326331 * @return void
327332 */
328333 private function parseBody () {
329- $ structure = imap_fetchstructure ($ this ->client ->connection , $ this ->uid , $ this ->fetch_options );
334+ $ structure = imap_fetchstructure ($ this ->client ->getConnection () , $ this ->uid , $ this ->fetch_options );
330335
331336 $ this ->fetchStructure ($ structure );
332337 }
@@ -350,7 +355,7 @@ private function fetchStructure($structure, $partNumber = null) {
350355
351356 $ encoding = $ this ->getEncoding ($ structure );
352357
353- $ content = imap_fetchbody ($ this ->client ->connection , $ this ->uid , $ partNumber , $ this ->fetch_options );
358+ $ content = imap_fetchbody ($ this ->client ->getConnection () , $ this ->uid , $ partNumber , $ this ->fetch_options );
354359 $ content = $ this ->decodeString ($ content , $ structure ->encoding );
355360 $ content = $ this ->convertEncoding ($ content , $ encoding );
356361
@@ -369,7 +374,7 @@ private function fetchStructure($structure, $partNumber = null) {
369374
370375 $ encoding = $ this ->getEncoding ($ structure );
371376
372- $ content = imap_fetchbody ($ this ->client ->connection , $ this ->uid , $ partNumber , $ this ->fetch_options );
377+ $ content = imap_fetchbody ($ this ->client ->getConnection () , $ this ->uid , $ partNumber , $ this ->fetch_options );
373378 $ content = $ this ->decodeString ($ content , $ structure ->encoding );
374379 $ content = $ this ->convertEncoding ($ content , $ encoding );
375380
@@ -423,7 +428,7 @@ protected function fetchAttachment($structure, $partNumber){
423428 break ;
424429 }
425430
426- $ content = imap_fetchbody ($ this ->client ->connection , $ this ->uid , ($ partNumber ) ? $ partNumber : 1 , $ this ->fetch_options );
431+ $ content = imap_fetchbody ($ this ->client ->getConnection () , $ this ->uid , ($ partNumber ) ? $ partNumber : 1 , $ this ->fetch_options );
427432
428433 $ attachment = new \stdClass ;
429434 $ attachment ->type = $ type ;
@@ -576,7 +581,7 @@ public function moveToFolder($mailbox = 'INBOX'){
576581 * @return bool
577582 */
578583 public function delete (){
579- $ status = imap_delete ($ this ->client ->connection , $ this ->uid , $ this ->fetch_options );
584+ $ status = imap_delete ($ this ->client ->getConnection () , $ this ->uid , $ this ->fetch_options );
580585 $ this ->client ->expunge ();
581586
582587 return $ status ;
@@ -588,7 +593,7 @@ public function delete(){
588593 * @return bool
589594 */
590595 public function restore (){
591- return imap_undelete ($ this ->client ->connection , $ this ->message_no );
596+ return imap_undelete ($ this ->client ->getConnection () , $ this ->message_no );
592597 }
593598
594599 /**
@@ -600,6 +605,10 @@ public function getAttachments(){
600605 return collect ($ this ->attachments );
601606 }
602607
608+ public function getHeader (){
609+ return $ this ->header ;
610+ }
611+
603612 /**
604613 * @return Client
605614 */
0 commit comments