Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I use move() for move message to another folder, but not working. #123

Open
nhatlinhle opened this issue Apr 5, 2021 · 2 comments
Open

Comments

@nhatlinhle
Copy link

I want to move message from folder INBOX to another folder, i am try follow code:

$client->connect();
//Get all Mailboxes
/** @var \Webklex\IMAP\Support\FolderCollection $folders */
$folders = $client->getFolder('INBOX');
/** @var \Webklex\IMAP\Message $detail */
$detail = $folders->messages()->getMessageByUid($uid = $id);
// $detail->delete($expunge = true);
$message = $detail->move('TRASH');
 if ($message == true) {
      dd('Message has ben moved');
  } else {
      dd('False');
  }

but always return false.
I have created folder TRASH, and i have collection folder in image:
image

I am tried copy() is working, but move() is not work.
Please help!

@nhatlinhle nhatlinhle changed the title I use move() for remove message to another folder, but not working. I use move() for move message to another folder, but not working. Apr 5, 2021
@zssarkany
Copy link

zssarkany commented Apr 6, 2021

Some IMAP servers don't support MOVE and UID MOVE IMAP commands, which are used by the move() method of this library. I'm currently debugging the same issue to write a highly detailed issue about this. You can try to use the legacy protocol implementation by changing 'protocol' => 'imap', to 'protocol' => 'legacy-imap', in your configuration, or you can mimic the same behavior as the legacy protocol works by copy the message to trash, and delete the original. In this case, you should think about when to expunge the original (\Deleted flagged) message. (Performance and message id considerations)

Edit: LegacyProtocol relies on imap_* PHP methods, therefore you need imap PHP extension to be installed, probably with SSL support. Check your phpinfo() first.

Edit2: I rather don't recommend using LegacyProtocol, because latest (2.5.0) version:

@nhatlinhle
Copy link
Author

Some IMAP servers don't support MOVE and UID MOVE IMAP commands, which are used by the move() method of this library. I'm currently debugging the same issue to write a highly detailed issue about this. You can try to use the legacy protocol implementation by changing 'protocol' => 'imap', to 'protocol' => 'legacy-imap', in your configuration, or you can mimic the same behavior as the legacy protocol works by copy the message to trash, and delete the original. In this case, you should think about when to expunge the original (\Deleted flagged) message. (Performance and message id considerations)

Thanks for the reply, I temporarily using copy the message to trash, and delete the original. Hope you fix it soon.
Have nice day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants