Cyrus managment from php..

Andrew Morgan morgan at orst.edu
Tue Jun 26 15:30:35 EDT 2007


On Tue, 26 Jun 2007, Kristaps Armanis wrote:

> JV> Anyone could share or point to some simple Cyrus managment
> JV> function list/class writenn in PHP based on sockets?
> JV> I guess pecl.php.net/cyrus  is pretty out of date?
>
> Is there any way to query cyrus from admin user over imap
> connection to get back users partition?

The "info" command in cyradm reports the partition.  Here is some perl 
code we use to determine which murder backend a mailbox is stored on. 
You could modify this easily to look at the partition instead.

--------------------------------------
sub locatemailbox {
         my ($server, $authuser, $authpw, $mailbox) = @_;
         my $location = "";

         use Mail::IMAPClient;

         my $imap = Mail::IMAPClient->new(
                                 Server => $server,
                                 User => $authuser,
                                 Password => $authpw
                         );
         if (! $imap) {
                 die("Cannot connect to mail server '$server' to locate mailbox - $!");
         }

         my @results = $imap->tag_and_run(qq/GETANNOTATION $mailbox "*" "value.shared"/);

         $imap->logout;

         foreach my $r (@results) {
                 $r =~ s/\r//g;
                 $r =~ s/\n//g;
                 if ($r =~ /\/vendor\/cmu\/cyrus-imapd\/server" \("value.shared" "(.*)"\)$/) {
                         $location = $1;
                 }
         }

         if ($location eq '') {
                 die("Cannot locate mailbox '$mailbox'.\n");
         }

         return $location;
}
--------------------------------------


 	Andy


More information about the Info-cyrus mailing list