php-imap
php-imap copied to clipboard
Messages not moved with Courier IMAP
Describe the bug I have a server running Courier IMAP, deleting messages and sending an expunge works perfectly but because I'm required to keep the messages on the server, move them to a folder and let the customer delete them afterwards.
Code to Reproduce
$folder->getClient()->getConnection()->enableDebug();
$message = $folder->messages()->getMessage($msgid);
if ($account->isImap()) {
$message->move('INBOX'.$folder->delimiter.'procesados');
} else {
$message->delete();
}
Expected behavior Move the message to the "processed" folder.
Desktop / Server (please complete the following information):
- OS: Debian 9
- PHP: 7.4.29
- Version [e.g. v2.3.1]
- Provider: Courier IMAP
Here's the protocol exchange since the moment i'm trying to move the message:
>> TAG16 SELECT "INBOX.procesados"
<< * FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
<< * OK [PERMANENTFLAGS (\* \Draft \Answered \Flagged \Deleted \Seen)] Limited
<< * 0 EXISTS
<< * 0 RECENT
<< * OK [UIDVALIDITY 664533991] Ok
<< * OK [MYRIGHTS "acdilrsw"] ACL
<< TAG16 OK [READ-WRITE] Ok
>> TAG17 EXAMINE "INBOX.procesados"
<< * FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
<< * OK [PERMANENTFLAGS ()] No permanent flags permitted
<< * 0 EXISTS
<< * 0 RECENT
<< * OK [UIDVALIDITY 664533991] Ok
<< * OK [MYRIGHTS "acdilrsw"] ACL
<< TAG17 OK [READ-ONLY] Ok
>> TAG18 EXPUNGE
<< TAG18 NO Cannot expunge read-only mailbox.
>> TAG19 LOGOUT
<< * BYE Courier-IMAP server shutting down
<< TAG19 OK LOGOUT completed
Hi @rmontagud ,
many thanks for your detailed report.
This looks like the folder you are trying to move to is in a "read-only" mode: TAG18 NO Cannot expunge read-only mailbox..
At least that how I would read this error message. Can you move the message to a folder which isn't in "read-only" mode?
Best regards,
Hi @Webklex ,
I've tried to move the message using roundcube and i've been able to do it so it doesn't seem a read-only issue... i've changed the destination folder to "Drafts" in my code and the result is the same
>> TAG14 SELECT "INBOX.Drafts"
<< * FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
<< * OK [PERMANENTFLAGS (\* \Draft \Answered \Flagged \Deleted \Seen)] Limited
<< * 0 EXISTS
<< * 0 RECENT
<< * OK [UIDVALIDITY 666948962] Ok
<< * OK [MYRIGHTS "acdilrsw"] ACL
<< TAG14 OK [READ-WRITE] Ok
>> TAG15 EXAMINE "INBOX.Drafts"
<< * FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
<< * OK [PERMANENTFLAGS ()] No permanent flags permitted
<< * 0 EXISTS
<< * 0 RECENT
<< * OK [UIDVALIDITY 666948962] Ok
<< * OK [MYRIGHTS "acdilrsw"] ACL
<< TAG15 OK [READ-ONLY] Ok
>> TAG16 EXPUNGE
<< TAG16 NO Cannot expunge read-only mailbox.
>> TAG17 LOGOUT
<< * BYE Courier-IMAP server shutting down
<< TAG17 OK LOGOUT completed
After a google search I ended in a bugreport from MailKit where it seems that if you send the EXAMINE command the folder stays as read-only (which might match the answer to TAG15?).
Also, I've noticed $message->move('INBOX'.$folder->delimiter.'procesados'); returns null, so I suspect the actual MOVE command has not been sent at all because Message::move() cannot determine the "uidnext".