Skip to content

Commit c47006f

Browse files
committed
Add more message operations
1 parent 7d4b2a7 commit c47006f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/Message.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,46 @@ public function flag(array|string $flag, string $operation = '+', bool $expunge
411411
}
412412
}
413413

414+
/**
415+
* Copy the message to the given folder.
416+
*/
417+
public function copy(string $folder, bool $expunge = true): void
418+
{
419+
$this->folder->mailbox()
420+
->connection()
421+
->copyMessage($folder, $this->folder->path(), $this->uid);
422+
423+
if ($expunge) {
424+
$this->folder->expunge();
425+
}
426+
}
427+
428+
/**
429+
* Move the message to the given folder.
430+
*/
431+
public function move(string $folder, bool $expunge = true): void
432+
{
433+
$this->folder->mailbox()
434+
->connection()
435+
->moveMessage($folder, $this->folder->path(), $this->uid);
436+
437+
if ($expunge) {
438+
$this->folder->expunge();
439+
}
440+
}
441+
442+
/**
443+
* Delete the message.
444+
*/
445+
public function delete(bool $expunge = true): void
446+
{
447+
$this->markDeleted();
448+
449+
if ($expunge) {
450+
$this->folder->expunge();
451+
}
452+
}
453+
414454
/**
415455
* Parse the message into a MailMimeMessage instance.
416456
*/

0 commit comments

Comments
 (0)