Skip to content

Commit

Permalink
Legacy support for moveManyMessages and copyManyMessages added
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Sep 4, 2021
1 parent 622fd5d commit bd123fa
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Connection/Protocols/LegacyProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,24 @@ public function copyMessage($folder, $from, $to = null, $uid = false) {
return \imap_mail_copy($this->stream, $from, $folder, $uid ? IMAP::FT_UID : IMAP::NIL);
}

/**
* Copy multiple messages to the target folder
*
* @param array<string> $messages List of message identifiers
* @param string $folder Destination folder
* @param bool $uid Set to true if you pass message unique identifiers instead of numbers
* @return array|bool Tokens if operation successful, false if an error occurred
*/
public function copyManyMessages($messages, $folder, $uid = false) {
foreach($messages as $msg) {
if ($this->copyMessage($folder, $msg, null, $uid) == false) {
return false;
}
}

return $messages;
}

/**
* Move a message set from current folder to an other folder
* @param string $folder destination folder
Expand All @@ -406,6 +424,24 @@ public function moveMessage($folder, $from, $to = null, $uid = false) {
return \imap_mail_move($this->stream, $from, $folder, $uid ? IMAP::FT_UID : IMAP::NIL);
}

/**
* Move multiple messages to the target folder
*
* @param array<string> $messages List of message identifiers
* @param string $folder Destination folder
* @param bool $uid Set to true if you pass message unique identifiers instead of numbers
* @return array|bool Tokens if operation successful, false if an error occurred
*/
public function moveManyMessages($messages, $folder, $uid = false) {
foreach($messages as $msg) {
if ($this->moveMessage($folder, $msg, null, $uid) == false) {
return false;
}
}

return $messages;
}

/**
* Create a new folder (and parent folders if needed)
* @param string $folder folder name
Expand Down

0 comments on commit bd123fa

Please sign in to comment.