laminas / laminas-mail

Provides generalized functionality to compose and send both text and MIME-compliant multipart e-mail messages
https://docs.laminas.dev/laminas-mail/
BSD 3-Clause "New" or "Revised" License
94 stars 64 forks source link

Can't set \Unseen flag #179

Open DigitalCyberSoft opened 2 years ago

DigitalCyberSoft commented 2 years ago

Current requests for the body of an IMAP message don't perform a .PEEK request. As a result I've tried (along with a few variations)

$conn->setFlags($uid, ['\Unseen']);

Result is Exception: cannot set flags, have you tried to set the recent flag or special chars?

Setting a message as \Seen works fine.

Alternatively I overrode getRawContent to perform a RFC822.TEXT.PEEK rather than RFC822.TEXT, however this crashes out as well.

Is there either a way to PEEK a message or set it to unseen?

NIitrix commented 2 years ago

same issue here!

NIitrix commented 2 years ago

I found a way to do it, you need to use the parameter $mode ('+' and '-') in function store in class Imap located here vendor/laminas/laminas-mail/src/Protocol/Imap.php

DigitalCyberSoft commented 2 years ago

Cheers for that. Seem like there should be a way to get to that from setFlags

Anyway, workaround code:

class MyImap extends Laminas\Mail\Storage\Imap
{
        public function getProtocol()
        {
                return $this->protocol;
        }
}
$conn->getProtocol()->store(['\Seen'], $uid, null, '-');

To be run after anything like getMessage() or getRawContent()

NIitrix commented 2 years ago

Yep! that will do the job.