#!/usr/bin/perl
#"authenticate" ["--minssf" N] ["--maxssf" N] ["--mechanisms" list] [user]
#use strict;
use Cyrus::IMAP::Admin;

my $server='dein_server';
my $admin='cyrus_admin_user';
my $pass='cyrus_admin_passwort';
$user=$ARGV[0];
$quota='204800'; # default quota

my $cyradm = Cyrus::IMAP::Admin->new($server) or
      die "$0: Unable to connect to IMAP server '$server': $!" ;
   $cyradm->authenticate(-user => $admin, -password => $pass, -mechanism => "LOGIN") or   
			die "$0: Failed to authenticate to IMAP server as '$server': $!";
   # create top of mailbox
   $cyradm->createmailbox("user.$user") or
      warn "$0: Unable to createmailbox for $user on mailbox user.$user : $!";
   # create default folder trash
   $cyradm->createmailbox("user.$user.trash") or
      warn "$0: Unable to createmailbox for $user.Trash on mailbox user.$user : $!";
   # create default folder drafts
   $cyradm->createmailbox("user.$user.drafts") or
      warn "$0: Unable to createmailbox for $user.Drafts on mailbox user.$user : $!";
   # create default folder sent-mail
   $cyradm->createmailbox("user.$user.sent-mail") or
      warn "$0: Unable to createmailbox for $user.Sent on mailbox user.$user : $!";
   # set default rights for admin user (delete, create)
   $cyradm->setacl("user.$user", $admin => "dc") or
      warn "$0: Unable to setacl for $user on mailbox user.$user : $!";
   # set default quota
   $cyradm->setquota("user.$user", STORAGE,$quota) or
     	warn "$0: Unable to set quota for $box : $!";
