How do I assign a specific flag to an email?

How do I assign a specific flag to an email?

Hello and welcome to our forums! :smiley:

Do you mean the IMAP protocol and the related flags?

Then please have a look at the Laminas\Mail\Storage\Imap::setFlags() method:

I need to assign the unseen flag to a specific email but I see the method setFlags it tells me that it cannot.

/**
           * set flags for message
           *
           * NOTE: this method can't set the recent flag.
           *
           * @param int $id number of message
           * @param array $flags new flags for message
           * @throws Exception\RuntimeException
           */

for that case should I use a custom flag?

$mail->setFlags($mesaggeid, [$customflag]);

How can I prevent the seen flag from being assigned automatically to a new email each time it arrives at the mailbox?