#!/usr/bin/perl -w
#
# Delete's a user from Cyrus
#

if ($#ARGV < 0) {
	print "Usage: $0 username\n";
	print "  Delete's a user from Cyrus\n";
	exit(-1);
}

use IMAP::Admin;

require "/private/admin/acct/email/prefs.pl";
require "/private/admin/acct/email/utils.pl";

my $imap = IMAP::Admin->new('Server' => $prefs{'cyrushost'},
			'Login' => $prefs{'cyrususer'},
			'Password' => $prefs{'cyruspass'},
			);

if (! $imap) {
	print "Error connecting to IMAP server.\n";
	exit;
}

my $username = $ARGV[0];
my $mailbox = "user.$username";

my $rv = &deletemailbox($imap, $mailbox);

if ($rv ne "success") {
	print "$rv\n";
}
else {
	print "Successfully deleted mailbox for $username\n";
}

$imap->close;

