Skip to content

Commit d4f8ef4

Browse files
authored
Merge pull request #219 from cristicotet/master
#218 Fix switchMailbox
2 parents 656ec7b + c4878fb commit d4f8ef4

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/PhpImap/Mailbox.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function getImapStream($forceConnection = true) {
123123
*/
124124
public function switchMailbox($imapPath) {
125125
$this->imapPath = $imapPath;
126-
$this->imap('reopen', $this->imapPath,false);
126+
$this->imap('reopen', $this->imapPath);
127127
}
128128

129129
protected function initImapStreamWithRetry() {
@@ -793,7 +793,41 @@ public function getMailboxes($search = "*") {
793793
}
794794
return $arr;
795795
}
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+
}
796815

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+
}
797831
/**
798832
* Call IMAP extension function call wrapped with utf7 args conversion & errors handling
799833
*

0 commit comments

Comments
 (0)