Skip to content

Commit 781133d

Browse files
committed
Get Folder instance by name
1 parent 66ee61d commit 781133d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/IMAP/Client.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,30 @@ public function disconnect() {
221221
return $this;
222222
}
223223

224+
/**
225+
* Get a folder instance by a folder name
226+
* -------------------------------------------------------
227+
* PLEASE NOTE: This is a completely experimental function
228+
* -------------------------------------------------------
229+
* @param string $folder_name
230+
* @param int $attributes
231+
* @param null|string $delimiter
232+
*
233+
* @return Folder
234+
*/
235+
public function getFolder($folder_name, $attributes = 32, $delimiter = null){
236+
237+
$delimiter = $delimiter == null ? config('imap.options.delimiter', '/') : $delimiter;
238+
239+
$oFolder = new Folder($this, (object)[
240+
'name' => $this->getAddress().$folder_name,
241+
'attributes' => $attributes,
242+
'delimiter' => $delimiter
243+
]);
244+
245+
return $oFolder;
246+
}
247+
224248
/**
225249
* Get folders list.
226250
* If hierarchical order is set to true, it will make a tree of folders, otherwise it will return flat array.

src/config/imap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
|--------------------------------------------------------------------------
7070
|
7171
| Available php imap config parameters are listed below
72+
| -Delimiter (optional):
73+
| This option is only used wehen calling $oClient->
74+
| You can use any supported char such as ".", "/", (...)
7275
| -Fetch option:
7376
| FT_UID - Message marked as read by fetching the message
7477
| FT_PEEK - Fetch the message without setting the "read" flag
@@ -80,6 +83,7 @@
8083
|
8184
*/
8285
'options' => [
86+
'delimiter' => '/',
8387
'fetch' => FT_UID,
8488
'open' => [
8589
// 'DISABLE_AUTHENTICATOR' => 'GSSAPI'

0 commit comments

Comments
 (0)