Leena Heino Leena.Heino at uta.fi
Thu Apr 21 11:34:08 EDT 2016

On Wed, 20 Apr 2016, Anatoli via Cyrus-devel wrote:

> The T199 actually mentions exactly this behavior. Why do you think that this
> is not a bug? How is it supposed the specialuse flag should be set from
> cyradm? OR, what does the specialuse property from getmd mean if it's not
> the same as SPECIAL-USE extension flag accessible via IMAP?

During the discussions in irc it became clear that it was not really a 
bug, but more like a feature request. I filed the T199 after irc 
discussions so that the idea would not get lost.

You can set or clear user's specialuse metadata with cyradm but you have 
to do it via proxy authentication: authenticate as admin but authorize as 
the user.

% cyradm --user cyrus --authz user --auth plain imap-server
imap-server> setmd Spam /private/specialuse Junk
imap-server> getmd Spam /private/specialuse
     specialuse: \Junk

Attached to this message is a perl script to set specialuse metadata.

   Leena Heino              University of Tampere / Computer Centre
   ( liinu at uta.fi )      ( http://www.uta.fi/laitokset/tkk )
-------------- next part --------------
use Cyrus::IMAP::Admin;

my @res = ();
my $server;
my $authm;
my $user;
my $authz;
my $pass;
my $cafile = "/etc/pki/tls/certs/ca-bundle.crt";

$authm = "login";
$server = "imap-server";
$user = "cyrus";
$authz = "cyrus";
$authz = "user";
$authm = "plain";
$pass = "your-admin-password";

my $cyrus = Cyrus::IMAP::Admin->new($server, '143');

$cyrus->authenticate(-authz => $authz, -user => $user, -password => $pass, -mechanism => $authm, -cafile => $cafile) or die "cannot authenticate to server with login as $user\n";
print "user set specialuse metadata for default folders: ";
@res = $cyrus->listmailbox("INBOX");
if (!@res) {
    print "No mailbox.\n";
} else {
    @res = $cyrus->listmailbox("*");
    if (!@res) {
    } else {
        if ($cyrus->setmetadata("Sent", "/private/specialuse", "Sent")) {
            $cyrus->setmetadata("Sent Items", "/private/specialuse", "none");
        } elsif ($cyrus->setmetadata("Sent Items", "/private/specialuse", "Sent")) {
            $cyrus->setmetadata("Sent", "/private/specialuse", "none");
        if ($cyrus->setmetadata("Trash", "/private/specialuse", "Trash")) {
            $cyrus->setmetadata("Deleted Items", "/private/specialuse", "none");
        } elsif ($cyrus->setmetadata("Deleted Items", "/private/specialuse", "Trash")) {
            $cyrus->setmetadata("Trash", "/private/specialuse", "none");
        if ($cyrus->setmetadata("Spam", "/private/specialuse", "Junk")) {
            $cyrus->setmetadata("Junk Email", "/private/specialuse", "none");
        } elsif ($cyrus->setmetadata("Junk Email", "/private/specialuse", "Junk")) {
            $cyrus->setmetadata("Spam", "/private/specialuse", "none");
        $cyrus->setmetadata("Drafs", "/private/specialuse", "Drafts");
        #$cyrus->setmetadata("Notes", "/private/specialuse", "Notes");
        $cyrus->setmetadata("Archives", "/private/specialuse", "Archive");
        print "OK.\n";

More information about the Cyrus-devel mailing list