From c47006f6f5e2bdbd87ca373fb67b8f0fd47b4040 Mon Sep 17 00:00:00 2001 From: Steve Bauman Date: Sat, 8 Feb 2025 18:02:36 -0500 Subject: [PATCH] Add more message operations --- src/Message.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/Message.php b/src/Message.php index b349dba..3ed3982 100644 --- a/src/Message.php +++ b/src/Message.php @@ -411,6 +411,46 @@ public function flag(array|string $flag, string $operation = '+', bool $expunge } } + /** + * Copy the message to the given folder. + */ + public function copy(string $folder, bool $expunge = true): void + { + $this->folder->mailbox() + ->connection() + ->copyMessage($folder, $this->folder->path(), $this->uid); + + if ($expunge) { + $this->folder->expunge(); + } + } + + /** + * Move the message to the given folder. + */ + public function move(string $folder, bool $expunge = true): void + { + $this->folder->mailbox() + ->connection() + ->moveMessage($folder, $this->folder->path(), $this->uid); + + if ($expunge) { + $this->folder->expunge(); + } + } + + /** + * Delete the message. + */ + public function delete(bool $expunge = true): void + { + $this->markDeleted(); + + if ($expunge) { + $this->folder->expunge(); + } + } + /** * Parse the message into a MailMimeMessage instance. */