[RCD] How to query IMAP Flag from within a plugin?

Benoit Panizzon benoit.panizzon at imp.ch
Mon Aug 14 08:33:18 CEST 2017

Hi Thomas

Thank you for your reply.

> It's probably worth to look a the thunderbird_labels plugin for
> Roundcube [1]. It uses IMAP flags to store custom labels.
> Custom flags need to be supported by the IMAP server with the
> PERMANENTFLAGS capability. You can check this with the following
> command from within a plugin:

Thank you, Brendan already pointed out to me, that custom flags
retrieval support is built in in RC via list_flags function.

> $this->rc->storage->check_permflag('Junk') ||
> $RCMAIL->storage->check_permflag('*');
> Then setting and unsetting those flags should be possible.
> In order to check a certain flag, you have to test it in the message
> object and not the IMAP storage instance in Roundcube. Do this in one
> of the message hooks like message_load [2] or messages_list [3]:
>   if (!empty($message->headers->flags['Junk']))

Yes I had a look at this function.

Unfortunately, as far as I have found out, custom flags are not returned
nor queried by the header->flags function. But list_flags looks
promising, my first test dumped all the custom flags of the messages
submitted to that function. Now I just have to build some logic around
to filter out the already reported (flagged as JUNK) messages from the
array the of msg_id's the customer is reporting. I suppose I will get
that done today :-)

-Benoît Panizzon-
I m p r o W a r e   A G    -    Leiter Commerce Kunden

Zurlindenstrasse 29             Tel  +41 61 826 93 00
CH-4133 Pratteln                Fax  +41 61 826 93 01
Schweiz                         Web  http://www.imp.ch

More information about the dev mailing list