Skip to content

Commit e7cf907

Browse files
committed
Message::moveToFolder() fetches new Message::class afterwards #31
1 parent 3b8d650 commit e7cf907

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/IMAP/Message.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,14 +950,25 @@ public function getContainingFolder(Folder $folder = null) {
950950
* @param bool $expunge
951951
* @param bool $create_folder
952952
*
953-
* @return bool
953+
* @return Message
954954
* @throws Exceptions\ConnectionFailedException
955+
* @throws InvalidMessageDateException
955956
*/
956957
public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
957958

958959
if($create_folder) $this->client->createFolder($mailbox, true);
959960

960-
return imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
961+
$target_folder = $this->client->getFolder($mailbox);
962+
$target_status = $target_folder->getStatus(IMAP::SA_ALL);
963+
964+
$status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
965+
if($status === true){
966+
if($expunge) $this->client->expunge();
967+
968+
return $target_folder->getMessage($target_status->uidnext);
969+
}
970+
971+
return null;
961972
}
962973

963974
/**

0 commit comments

Comments
 (0)