require
'io_exception_dbg.pl'
;
eval
{
print
"Net::Axigen sample. Add account in the domain. Set account data.\n\n"
;
print
'Host: '
;
my
$host
=<STDIN>;
chomp
(
$host
);
print
'Port: '
;
my
$port
=<STDIN>;
chomp
(
$port
);
print
'Axigen admin password: '
;
my
$password
=<STDIN>;
chomp
(
$password
);
my
$axi
= Net::Axigen->new(
$host
,
$port
,
'admin'
,
$password
, 10);
$axi
->
connect
();
my
(
$version_major
,
$version_minor
,
$version_revision
)=
$axi
->get_version();
my
(
$os_version_full
,
$os_name
,
$os_version_platform
)=
$axi
->get_os_version();
print
"\n\nAxigen Version: "
.
$version_major
.
'.'
.
$version_minor
.
'.'
.
$version_revision
.
", OS: "
.
$os_version_full
.
"\n"
;
my
$domain_list
=
$axi
->listDomains();
print
"List of domains:\n"
;
print
"------------\n"
;
foreach
my
$ptr
(
@$domain_list
) {
print
"$ptr\n"
; }
print
"------------\n\n"
;
print
'The domain in which the account will be added: '
;
my
$domain
=<STDIN>;
chomp
(
$domain
);
my
$account_list
=
$axi
->listAccounts(
$domain
);
print
"\nCurrent account list\n"
;
print
"------------\n"
;
foreach
my
$ptr
(
@$account_list
) {
print
"$ptr\n"
; }
print
"------------\n"
;
print
'New account: '
;
my
$acc
=<STDIN>;
chomp
(
$acc
);
print
'Account password: '
;
my
$accpassword
=<STDIN>;
chomp
(
$accpassword
);
print
"\nCreate account $acc"
.
'@'
.
"$domain with password $accpassword? (yes/no)"
;
my
$create
=<STDIN>;
chomp
(
$create
);
if
(
$create
eq
'yes'
)
{
$axi
->addAccount(
$domain
,
$acc
,
$accpassword
);
$axi
->{ locale } =
'windows-1251'
;
$axi
->setAccountContactData(
$domain
,
$acc
,
"Àëåêñàíäð"
,
"Ôðîëîâ"
);
my
$quota_subject
=
'ÂÍÈÌÀÍÈÅ! Ñêîðî áóäåò èñ÷åðïàíû êâîòû íà ïî÷òîâûé ÿùèê (%3.3p% èç %SKb è %3.3q% èç %C ñîîáùåíèé)'
;
my
$quota_msg
=
'Çäðàâñòâóéòå, %N'
.
"\n\n"
;
$quota_msg
=
$quota_msg
.
'Âàø ïî÷òîâûé ÿùèê %A@%D ñêîðî ïåðåïîëíèòñÿ:'
.
"\n"
;
$quota_msg
=
$quota_msg
.
'îáùèé ðàçìåð ñîîáùåíèé: %sKb (ïðåäåë %SKb);'
.
"\n"
;
$quota_msg
=
$quota_msg
.
'êîëè÷åñòâî ñîîáùåíèé: %c (ïðåäåë %C)'
.
"\n\n"
;
$quota_msg
=
$quota_msg
.
'Åñëè ïî÷òîâûé ÿùèê ïåðåïîëíèòñÿ, Âû íå ñìîæåòå áîëüøå ïîëó÷àòü ñîîáùåíèÿ. '
;
$quota_msg
=
$quota_msg
.
'×òîáû ýòîãî èçáåæàòü, ïîæàëóéñòà óäàëèòå ÷àñòü ñîîáùåíèé.'
.
"\n\n"
;
$quota_msg
=
$quota_msg
.
'Ñ óâàæåíèåì, Àäìèíèñòðàöèÿ.'
.
"\n"
;
$axi
->setQuotaLimitNotification(
$domain
,
$acc
,
$quota_subject
,
$quota_msg
);
$axi
->setAccountPassword(
$domain
,
$acc
,
$accpassword
);
$axi
->setAccountWebMailLanguage(
$domain
,
$acc
,
'ru'
);
my
$account_list
=
$axi
->listAccounts(
$domain
);
print
"\nNew account list\n"
;
print
"------------\n"
;
foreach
my
$ptr
(
@$account_list
) {
print
"$ptr\n"
; }
print
"------------\n"
;
}
my
$ok
=
$axi
->
close
();
print
'End: '
.
"$ok\n"
;
};
io_exception_dbg->
catch
($@);