Skip to content

Commit bd123fa

Browse files
committed
Legacy support for moveManyMessages and copyManyMessages added
1 parent 622fd5d commit bd123fa

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/Connection/Protocols/LegacyProtocol.php

+36
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,24 @@ public function copyMessage($folder, $from, $to = null, $uid = false) {
392392
return \imap_mail_copy($this->stream, $from, $folder, $uid ? IMAP::FT_UID : IMAP::NIL);
393393
}
394394

395+
/**
396+
* Copy multiple messages to the target folder
397+
*
398+
* @param array<string> $messages List of message identifiers
399+
* @param string $folder Destination folder
400+
* @param bool $uid Set to true if you pass message unique identifiers instead of numbers
401+
* @return array|bool Tokens if operation successful, false if an error occurred
402+
*/
403+
public function copyManyMessages($messages, $folder, $uid = false) {
404+
foreach($messages as $msg) {
405+
if ($this->copyMessage($folder, $msg, null, $uid) == false) {
406+
return false;
407+
}
408+
}
409+
410+
return $messages;
411+
}
412+
395413
/**
396414
* Move a message set from current folder to an other folder
397415
* @param string $folder destination folder
@@ -406,6 +424,24 @@ public function moveMessage($folder, $from, $to = null, $uid = false) {
406424
return \imap_mail_move($this->stream, $from, $folder, $uid ? IMAP::FT_UID : IMAP::NIL);
407425
}
408426

427+
/**
428+
* Move multiple messages to the target folder
429+
*
430+
* @param array<string> $messages List of message identifiers
431+
* @param string $folder Destination folder
432+
* @param bool $uid Set to true if you pass message unique identifiers instead of numbers
433+
* @return array|bool Tokens if operation successful, false if an error occurred
434+
*/
435+
public function moveManyMessages($messages, $folder, $uid = false) {
436+
foreach($messages as $msg) {
437+
if ($this->moveMessage($folder, $msg, null, $uid) == false) {
438+
return false;
439+
}
440+
}
441+
442+
return $messages;
443+
}
444+
409445
/**
410446
* Create a new folder (and parent folders if needed)
411447
* @param string $folder folder name

0 commit comments

Comments
 (0)