|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39440 Custom IMAP flags cannot be fetched
Submitted: 2006-11-09 01:28 UTC Modified: -
Avg. Score:4.9 ± 0.4
Reproduced:24 of 34 (70.6%)
Same Version:14 (58.3%)
Same OS:7 (29.2%)
From: loikiolki at yahoo dot ca Assigned:
Status: Open Package: Feature/Change Request
PHP Version: 5.2.0 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: loikiolki at yahoo dot ca
New email:
PHP Version: OS:


 [2006-11-09 01:28 UTC] loikiolki at yahoo dot ca
None of the existing IMAP functions built into PHP support fetching custom IMAP flags. Existing functions imap_setflag_full and imap_clearflag_full allow one to set custom flags, but there is no method available to fetch them back.

Reproduce code:
    // clear custom flag
    imap_setflag_full($mbox, $msg_id, '$Label2');

    // set custom flag
    imap_setflag_full($mbox, $msg_id, '$Label1');

    // fetch the flag - we need this!
    if (imap_fetchflag_full($mbox, $msg_id, '$Label1'))
        echo "Flag \$Label1 is set\n";
        echo "Flag \$Label1 is not set\n";

    // also, maybe include custom flags in functions
    // such as imap_headerinfo() to fetch all set flags
    // (not sure if this is possible with IMAP protocol)

Expected result:
Flag $Label1 is set

Actual result:
Fatal error: Call to undefined function imap_fetchflag_full() in Command line code on line 1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-19 14:02 UTC] krisha at tvnet dot lv
Will anyone ever  fix this bug? :(
There for ages and still in 5.3..
 [2017-07-19 15:18 UTC] christof dot kudla at kudla dot info
It is possible to use the Zend framework as a workaround. To check for flags, Zend\Mail\Storage\Message has a method called hasFlag(). With getFlags() you'll get all flags.
 [2017-08-11 14:09 UTC] bp at imp dot ch
Same Problem here with a custom plugin to the widely used RoundCube Webmail Client.

The plugin report_junk does set a custom flag 'JUNK' to mark which emails habe been reported as junk.
But lacking and function to query for a custom email flag, it cannot detect if an email is already labeled junk and allows the user to report the same spam mail multiple times. Now what you want when your 'backend' scripts do generate an ARF report to the ISP of the sender.

Please do implement a php imap function to get all flags or query for the presence of a flag.


* imap_get_flags($mbox, $msg_id)
* imap_has_flag($mbox,$msg_id, 'JUNK')
 [2017-08-11 14:35 UTC] bp at imp dot ch
Just look at perl:

my $imap = Net::IMAP::Simple->new('', SSL_version => 'SSLv3 SSLv2 TLSv1', use_ssl => 0) ||
       die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n";

        print STDERR "Login failed: " . $imap->errstr . "\n";

    print "Available server flags: " . join(", ", $imap->flags) . "\n";

my @ids = $imap->search("SUBJECT \"V14gr4\" ");

    my $count = scalar @ids;
    print "Emails found: $count\n";

        foreach (@ids) {
                my $flags = $imap->msg_flags($_);
                print "Flags on message $_: $flags\n";


This results in an output like this showing all the flags, including the ones set with RoudCube using PHP:

Emails found: 1
Flags on message 30: \Seen JUNK
 [2022-01-03 14:43 UTC] emmanoaha784 at gmail dot com
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 00:01:28 2024 UTC