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

Thomas Bruederli thomas at roundcube.net
Sun Aug 13 21:45:07 CEST 2017

Hello Benoit

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:

$this->rc->storage->check_permflag('Junk') ||

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']))

I hope this helps you to proceed.


[1] https://github.com/mike-kfed/rcmail-thunderbird-labels
[2] https://github.com/roundcube/roundcubemail/wiki/Plugin-Hooks#message_load
[3] https://github.com/roundcube/roundcubemail/wiki/Plugin-Hooks#messages_list

On Fri, Aug 11, 2017 at 4:00 PM, Benoit Panizzon <benoit.panizzon at imp.ch> wrote:
> Well, I'm giving up.
> After consulting the PHP online manual on IMAP Flags and only finding
> functions to set and clear flags, but not to query then.
> And then after further research, stumbling over this article:
> https://stackoverflow.com/questions/32851152/how-to-read-apple-mail-custom-imap-flags-with-php
> Stating:
> "Actually you are not able to do so using standard imap extension as it
> is impossible to fetch custom flags using it."
> I suppose custom flags support has not been built into roundcube. If it
> is I would be glad if someone could correct me.
> Therefore I wonder, why plugins linke report_junk set the 'JUNK' flag
> if there is no way to query this flag from within roundcube.
> -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
> ______________________________________________________
> _______________________________________________
> Roundcube Development discussion mailing list
> dev at lists.roundcube.net
> http://lists.roundcube.net/mailman/listinfo/dev

More information about the dev mailing list