laminas-mail icon indicating copy to clipboard operation
laminas-mail copied to clipboard

Can't set \Unseen flag

Open DigitalCyberSoft opened this issue 3 years ago • 4 comments

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?

DigitalCyberSoft avatar Feb 11 '22 04:02 DigitalCyberSoft

same issue here!

NIitrix avatar Mar 29 '22 19:03 NIitrix

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

NIitrix avatar Mar 29 '22 21:03 NIitrix

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()

DigitalCyberSoft avatar Apr 01 '22 07:04 DigitalCyberSoft

Yep! that will do the job.

NIitrix avatar Apr 01 '22 15:04 NIitrix