diff --git a/src/Connection/Protocols/ImapProtocol.php b/src/Connection/Protocols/ImapProtocol.php index be1f0309..ddc77c4d 100644 --- a/src/Connection/Protocols/ImapProtocol.php +++ b/src/Connection/Protocols/ImapProtocol.php @@ -824,6 +824,25 @@ public function copyMessage($folder, $from, $to = null, $uid = false) { return $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); } + /** + * Copy multiple messages to the target folder + * + * @param array $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 + * + * @throws RuntimeException + */ + public function copyManyMessages($messages, $folder, $uid = false) { + $command = $uid ? 'UID COPY' : 'COPY'; + + $set = implode(',', $messages); + $tokens = [$set, $this->escapeString($folder)]; + + return $this->requestAndResponse($command, $tokens, true); + } + /** * Move a message set from current folder to an other folder * @param string $folder destination folder @@ -845,6 +864,25 @@ public function moveMessage($folder, $from, $to = null, $uid = false) { return $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); } + /** + * Move multiple messages to the target folder + * + * @param array $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 + * + * @throws RuntimeException + */ + public function moveManyMessages($messages, $folder, $uid = false) { + $command = $uid ? 'UID MOVE' : 'MOVE'; + + $set = implode(',', $messages); + $tokens = [$set, $this->escapeString($folder)]; + + return $this->requestAndResponse($command, $tokens, true); + } + /** * Create a new folder (and parent folders if needed) * @param string $folder folder name @@ -1032,4 +1070,4 @@ public function enableDebug(){ public function disableDebug(){ $this->debug = false; } -} \ No newline at end of file +}