How can the imap_mail_move() function in PHP be effectively used to move emails to a different mailbox?

To move emails to a different mailbox using the imap_mail_move() function in PHP, you need to specify the source mailbox, message number, and the destination mailbox. This function will then move the specified email to the new mailbox.

$imapStream = imap_open('{imap.example.com:993/ssl}INBOX', 'username', 'password');
$sourceMailbox = 'INBOX';
$destinationMailbox = 'Archive';
$messageNumber = 1;

if (imap_mail_move($imapStream, $messageNumber, $destinationMailbox)) {
    echo 'Email moved successfully.';
} else {
    echo 'Failed to move email.';
}

imap_close($imapStream);