#!%PERL% -w


use strict;

use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Conf;
use Vhffs::User;
use Vhffs::Group;
use Vhffs::Main;
use Vhffs::Object;
use Vhffs::Acl;
use Vhffs::Services::MailUser;
use Vhffs::Panel::Mail;

my $princ = init Vhffs::Main;

die("Usage: $0 username password\n") unless(@ARGV == 2);

my ($username, $password) = @ARGV;

my $user = Vhffs::User::get_by_username($princ, $username);
die("User not found\n") unless(defined $user);

my $mu = init Vhffs::Services::MailUser( $princ , $user );

die("Unable to create box $username\@".$mu->{domain}."\n") unless($mu->addbox( $password ) > 0);
print "Box $username\@".$mu->{domain}." created\n";
