@@ -123,7 +123,7 @@ public function getImapStream($forceConnection = true) {
123
123
*/
124
124
public function switchMailbox ($ imapPath ) {
125
125
$ this ->imapPath = $ imapPath ;
126
- $ this ->imap ('reopen ' , $ this ->imapPath , false );
126
+ $ this ->imap ('reopen ' , $ this ->imapPath );
127
127
}
128
128
129
129
protected function initImapStreamWithRetry () {
@@ -793,7 +793,41 @@ public function getMailboxes($search = "*") {
793
793
}
794
794
return $ arr ;
795
795
}
796
+ /**
797
+ * Get folders list
798
+ * @param string $search
799
+ * @return array
800
+ */
801
+ public function getSubscribedMailboxes ($ search = "* " ) {
802
+ $ arr = [];
803
+ if ($ t = imap_getsubscribed ($ this ->getImapStream (), $ this ->imapPath , $ search )) {
804
+ foreach ($ t as $ item ) {
805
+ $ arr [] = [
806
+ "fullpath " => $ item ->name ,
807
+ "attributes " => $ item ->attributes ,
808
+ "delimiter " => $ item ->delimiter ,
809
+ "shortpath " => substr ($ item ->name , strpos ($ item ->name , '} ' ) + 1 ),
810
+ ];
811
+ }
812
+ }
813
+ return $ arr ;
814
+ }
796
815
816
+ /**
817
+ * @param $mailbox
818
+ * @throws Exception
819
+ */
820
+ public function subscribeMailbox ($ mailbox ) {
821
+ $ this ->imap ('subscribe ' , $ this ->imapPath . '. ' . $ mailbox );
822
+ }
823
+
824
+ /**
825
+ * @param $mailbox
826
+ * @throws Exception
827
+ */
828
+ public function unsubscribeMailbox ($ mailbox ) {
829
+ $ this ->imap ('unsubscribe ' , $ this ->imapPath . '. ' . $ mailbox );
830
+ }
797
831
/**
798
832
* Call IMAP extension function call wrapped with utf7 args conversion & errors handling
799
833
*
0 commit comments