laminas-mail
laminas-mail copied to clipboard
Can't set \Unseen flag
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?
same issue here!
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
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()
Yep! that will do the job.