Checking for a mailbox's backend server

Andrew Morgan morgan at orst.edu
Tue Sep 19 14:53:40 EDT 2006


On Tue, 19 Sep 2006, Brenden Conte wrote:

> Is there a way to remotely find what backend server a specific mailbox is on 
> using the admin account?  This includes both users mailboxes as well as 
> shared mailboxes.

##########################
# Locate which backend a mailbox is on
##########################
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;
                 }
         }

         return $location;
}



 	Andy


More information about the Info-cyrus mailing list