check_mbox_mysql.pl
#!/usr/bin/perl

use Cyrus::IMAP::Admin;
use Mysql;

$server = 'localhost';
$adminuser = 'cyrus';
$adminpw = 'secret';

$imap = Cyrus::IMAP::Admin->new($server) || die "Unable to connect";
unless ($imap) {
  die "Error creating IMAP Connection object\n";
}
$imap->authenticate(-user => $adminuser, -password => $adminpw, -mechanism => "LOGIN");
if ($imap->error) {
  die $imap->error;
}

$sqluser = 'dbuser';
$sqlpass = 'secret';
$db = 'dbname';
$db = Mysql->connect($server, $db, $sqluser, $sqlpass);

$sqlquery = "SELECT username,realm FROM authreg ORDER BY realm,username";
$query = $db->query($sqlquery);
$i = 0;
while ( @array = $query->fetchrow ) {
  $users[$i] = $array[0] . "@" . $array[1];
  $i++;
}
foreach (@users) {
  $username = $_;
  @acl = $imap->listacl("user/$username");
  if ($imap->error) {
    print $username, " ERROR (no cyrus mbox)\n";
  } else {
    print $username, " OK\n";
  }
}
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki