CommuniGate Pro
 


 

CommuniGate Pro Perl Interface



The CommuniGate Pro CLI API can be used to automate the Server management and to integrate the CommuniGate Pro and other services.

The following document, scripts and samples should help you to integrate CommuniGate Pro with programs and CGI scripts written in the Perl language.

The CLI.pm package

The CLI.pm Perl module is the main component for CommuniGate Pro scripting. It contains the package CGP::CLI and includes the routines to connect to the CommuniGate Pro server over the network, to send CommuniGate Pro CLI commands and to convert command parameters from the Perl internal format into the CommuniGate Pro CLI format, and to convert command results back into the Perl internal format.

You should use the new CGP::CLI command to establish an authenticated connection with the CommuniGate Pro server and to create an interface object. Then you send commands to the server by calling various interface object methods.

Revision History.

Installation: Simply copy the CLI.pm file into one of the @INC directories. The list of @INC directories is displayed by perl -V command.

Note: The CGP::CLI class uses IO::Socket::INET class. Depending on your Perl setup, you may need to modify your CLI.pm file and change the use IO::Socket; line into use IO::Socket::INET;.

Note: The CLI.pm uses Digest::MD5 module. If you don't have MD5 module installed, you'll have to download and install it.

Sample Scripts

You can use the following sample scripts that employ the CGP::CLI package:

Script fileDescription
CreateUserCGI.pl This CGI script composes a custom Auto-Signup page and registers a user with the CommuniGate Pro Server.
CreateDomainCGI.pl This CGI script composes a custom domain registration page and registers a domain and postmaster account in that domain with the CommuniGate Pro Server.
ListAccounts.pl This script prints the list of domain accounts and their settings.
ListTotals.pl This script prints the number of accounts, groups and forwarders in each CommuniGate Pro domain and their total numbers.
RegUnixUsers.pl This script registers all Unix users (i.e. names in the /etc/passwd file) with the CommuniGate Pro Server.
DeleteUsers.pl This script reads an Account Import file and deletes all accounts listed in that file
DeleteInactive.pl This script deletes inactive accounts from the specified CommuniGate Pro domain.
ImportForwarders.pl Use this script to import Forwarders from a tab-delimitered file.
ImportGroup.pl Use this script to import and update Group members.
Web4All.pl This sample script modifies the WebSite-related settings in all accounts inside the specified CommuniGate Pro domain.
ChangeFrom.pl This sample script changes the From addresses of WebMail users inside the specified CommuniGate Pro domain.

There are more scripts in the Script Repository Page

The Package commands

Package Service Commands

new CGP::CLI( { PeerAddr=>CGPaddress, PeerPort=>port, login=>username, password=>password})
Use this command to connect to CommuniGate Pro and log into its PWD server.
Parameters:

PeerAddr: string
Domain name or IP address to connect to. The address can be follwed by port number.

port: string
Port number (use 106 for PWD). This parameter may be ommited if the port number is specified in PeerAddr.

username: string
The administrator account name. The name can contain a domain part.

password: string
The administrator account password.

SecureLogin: string
Optional parameter. If set to 0 it forces clear-text insecure (USER/PASS) login, otherwise it forces secure (APOP) login.

WebUserLogin: string
Optional parameter. If set to 1 it forces WEBUSER login. It can be used only when secure login is disabled.

SSLTransport: string
Optional parameter. If set to 1 it forces encrypted (SSL/TLS) connection, otherwise it uses unencrypted connection.

Returns:
a reference to a new class or undefined.

Example:

  my $cli = new CGP::CLI( { PeerAddr => 'company.com',
                            PeerPort => 106,
                            login    => 'postmaster@company.com',
                            password => 'pass',
                            SecureLogin => 0,
                            SSLTransport => 1
                        } )
            || die "Can't login to CGPro: ".$CGP::ERR_STRING."\n";
        

$CGP::SECURE_LOGIN
Contents of this variable specifies the default value for SecureLogin parameter of new CGP::CLI() command. By default it is set to 1 which means secure (APOP) login.

$CGP::WEBUSER_LOGIN
Contents of this variable specifies the default value for WebUserLogin parameter of new CGP::CLI() command. By default it is set to 0.

$CGP::SSL_TRANSPORT
Contents of this variable specifies the default value for SSLTransport parameter of new CGP::CLI() command. By default it is set to 0 which means unencrypted connection.

Example:

  $CGP::SECURE_LOGIN=0;
  $CGP::WEBUSER_LOGIN=1;
  $CGP::SSL_TRANSPORT=1;
  

Logout
Use this command to close the CommuniGate Pro CLI session.

Example:

  $cli->Logout();
  

getErrCode
Use this call to get the result code.

Returns:
the result code of the last CommuniGate Pro CLI operation. OK code is 200.

Example:

  if($cli->getErrCode!=200) { print "Something's wrong..."; }
  

getErrMessage
Use this call to get the result (error) string produced with the last CommuniGate Pro CLI operation.

Returns:
result message string from the last command.

Example:

  print "The last result message is ".$cli->getErrMessage."\n";
  

isSuccess
Use this call to check if the last operation was successful.

Returns:
TRUE if the result code is 200, FALSE otherwise.

getErrCommand
Use this call to get the full text of the last command sent to the CommuniGate Pro Server.

Returns:
the full text of the last command sent to CGPro via CGP::CLI.

NewPassword(newPassword)
Use this command to set the new password for the currently used administrator account.

Parameters:

newPassword: string
The new password.

SendCommand(command)
Use this call to send a direct command to CommuniGatePro CLI.

Returns:
TRUE or FALSE.

Example:

  $cli->SendCommand('CreateAccount john@domain.com {RealName="John X Smith";}')
        || die "Error: ".$cli->getErrMessage.", quitting";
  

GetResponseData
Use this call to get the output caused by SendCommand call (if any).

Returns:
The reference to the output data.

Example:

  $cli->SendCommand("ListAccounts")
        || die "Error: ".$cli->getErrMessage.", quitting";
  $AccountList=$cli->GetResponseData();

  foreach(keys %$AccountList) { print "$_\n"; }


The following commands resemble the CommuniGate Pro Server CLI commands, and use the Perl "hash" and "array" objects for the CommuniGate Pro "dictionary" and "array" objects and "string" ojects as CommuniGate Pro "string", "timestamp", "number", "IP address" and "datablock" objects. See the CommuniGate Pro CLI manual section for the details.

Account Administration Commands

ListDomainObjects (domainName,limit[,filter[,what[,cookie]]] )
Example:
my $data=$cli->ListDomainObjects('company.com',1000,undef,'ACCOUNTS ALIASES FORWARDERS','')
   || die "ListDomainObjects failed: ".$cli->getErrMessage.", quitting";

print "Accoints: $data->[0]\n";
print "Aliases: $data->[2]\n";
print "Forwarders: $data->[3]\n";
print "Objects are:\n";
foreach(keys %{$objects=$data->[1]} ) {
  print "  $_\n";
}

ListAccounts ( [domainName] )
Example:
  $AccountList = $cli->ListAccounts('company.com')
                 || die "Error: ".$cli->getErrMessage.", quitting";
  foreach(keys %$AccountList) { print "$_\n"; }

ListDomainTelnums (domainName,limit[,filter] )

CreateAccount( accountName => name, [ settings => userData, accountType => accountType, externalFlag => externalFlag ] );
Example:
  my $UserData = {
    AccessModes =>  [ qw(Mail POP IMAP PWD WebMail WebSite) ],
    RealName => 'John X. Smith',
    MaxAccountSize =>  '100K',
  };
  $cli->CreateAccount(accountName => 'john',settings => $UserData, )
        || die "Error: ".$cli->getErrMessage.", quitting";

RenameAccount(oldAccountName,newAccountName)
Example:
  $Domain = 'company.com';
  $cli->RenameAccount("johnsmith\@$Domain","js\@$Domain")
        || die "Can't rename: ".$cli->getErrMessage.", quitting";

DeleteAccount(oldAccountName)
Example:
  $cli->DeleteAccount("js")
        || die "Can't delete: ".$cli->getErrMessage.", quitting";

SetAccountType(AccountName,[MultiMailbox | AGrade | BGrade | CGrade])

GetAccountSettings(accountName)
Example:
if($Settings=$cli->GetAccountSettings('user')) {
  print "The settings are:\n";
  foreach (keys %$Settings) {
    print "  $_ = \"@$Settings{$_}\"\n";
  }
} else {
  die "Error: ".$cli->getErrMessage.", quitting";
}

GetAccountEffectiveSettings(accountName)

UpdateAccountSettings(accountName,newSettings)
Example:
  $cli->UpdateAccountSettings('john',{Password => 'pass',MaxAccountSize => 'Default'})
        || die "Error: ".$cli->getErrMessage.", quitting";

SetAccountSettings(accountName,newSettings)

SetAccountPassword(accountName,newPassword[,check[,method]])
Example:
  $cli->SetAccountPassword('john','newPass') 
        || die "Error: ".$cli->getErrMessage.", quitting";

VerifyAccountPassword(accountName,password)
Example:
  print($cli->VerifyAccountPassword('john','newPass') ? "correct\n" : "wrong\n");

GetAccountAliases(accountName)
Example:
  if($Aliases=$cli->GetAccountAliases('user')) {
    print "  $_\n" foreach (@$Aliases);
  } else {
    ($cli->isSuccess) ? print "No aliases\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

SetAccountAliases(accountName,newAliases)
Example:
  $cli->SetAccountAliases('john',['js','jsmith','john_smith']) 
        || die "Error: ".$cli->getErrMessage.", quitting";

GetAccountTelnums(accountName)
Example:
  if($Aliases=$cli->GetAccountTelnums('user')) {
    print "  $_\n" foreach (@$Aliases);
  } else {
    ($cli->isSuccess) ? print "No telnums\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

SetAccountTelnums(accountName,newTelnums)
Example:
  $cli->SetAccountTelnums('john',['11110000','11110011']) 
        || die "Error: ".$cli->getErrMessage.", quitting";

GetAccountMailRules(accountName)
Example:
  my $Rules=$cli->GetAccountMailRules('john')
            || die "Error: ".$cli->getErrMessage.", quitting";

  foreach my $Rule (@$Rules) {
    my $conditions=$Rule->[2],$actions=$Rule->[3];
    print "\nName='$Rule->[1]' Priority=$Rule->[0]\n";
    print "  If\n  ";
    foreach my $cond (@$conditions) {
      print " $_ " foreach (@$cond);
      print "\n  ";
    }
    print "Then\n  ";
    foreach my $actn (@$actions) {
      print " $_ " foreach (@$actn);
      print "\n  ";
    }
  }

SetAccountMailRules(accountName,newRules)
Example:
  my @Rules =(
  [ 5, '#Vacation',
    [['Human Generated', '---']],
    [['Reply with', "Sorry, I'm on vacation"]]
  ],
  [ 5,'Mark Important Messages',
    [ ['Subject', 'is', '*important*'] ],
    [ ['Mark', 'Flagged'],
      ['FingerNotify', '123.45.67.89'],
      ['Forward to', 'my@home.address']
    ]
  ]
  );

  $cli->SetAccountMailRules('jonh',\@Rules)
        || die "Error: ".$cli->getErrMessage.", quitting";

UpdateAccountMailRule(accountName,newRule)

GetAccountSignalRules(accountName)

SetAccountSignalRules(accountName,newRules)

UpdateAccountSignalRule(accountName,newRule)

GetAccountRPOPs(accountName)
Example:
   my $records=$cli->GetAccountRPOPs('john')
              || die "Error: ".$cli->getErrMessage.", quitting";
  foreach(keys %$records) {
    print "Record: $_\n";
    my $rec=@$records{$_};
      foreach(keys %$rec) {
        print " $_=@$rec{$_}\n";
      }
  }

SetAccountRPOPs(accountName,newRecords)
Example:
   my $records=$cli->GetAccountRPOPs('john')
              || die "Error: ".$cli->getErrMessage.", quitting";
   my $newRecord={authName=>'john',domain=>'host.com',password=>'passw', APOP=>'YES',period=>'1200s'};
   @$records{'polling host.com'}=$newRecord;
   $cli->SetAccountRPOPs('john',$records)
              || die "Error: ".$cli->getErrMessage.", quitting";

GetAccountRSIPs(accountName)

SetAccountRSIPs(accountName,newRecords)

UpdateScheduledTask(accountName,taskData)

GetAccountRights(accountName)
Example:
  if($Rights=$cli->GetAccountRights('john')) {
    print "$_ " foreach (@$Rights); print "\n";
  } else {
    ($cli->isSuccess) ? print "No rights\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

SetAccountRights(accountName,newRights)
Example:
  $cli->SetAccountRights('john',['UserAccounts', 'ServerSettings', 'Monitor']) 
        || die "Error: ".$cli->getErrMessage.", quitting";

GetAccountInfo(accountName[,keyName | \@keys])
Example:
  if($Data=$cli->GetAccountInfo('john')) {
    print "The data are:\n";
    foreach (keys %$Data) {
      print "  $_ = \"@$Data{$_}\"\n";
    }
  } else {
    die "Error: ".$cli->getErrMessage.", quitting";
  }

  if($Data=$cli->GetAccountInfo('john','LastLogin')) {
    print "John\'s last login was on $Data\n";
  } else {
    ($cli->isSuccess) ? print "No such info\n"
    : die "Error: ".$cli->getErrMessage.", quitting";    

  

GetAccountPrefs(accountName)
Example:
  if($Settings=$cli->GetAccountPrefs('john')) {
    print "The settings are:\n";
    foreach (keys %$Settings) {
      print "  $_ = \"@$Settings{$_}\"\n";
    }
  } else {
    die "Error: ".$cli->getErrMessage.", quitting";
  }

SetAccountPrefs(accountName,newSettings)

UpdateAccountPrefs(accountName,newSettings)
Example:
  $Account='John';
  my %Settings=(
    Frames =>  'YES',
    DraftsBox =>  'DRAFTS',
    SentBox =>  'OUTBOX',
    Signature =>  'Sincerely yours,\e '.$Account
  );
  $cli->UpdateAccountPrefs($Account,\%Settings) ||
        die "Error: ".$cli->getErrMessage.", quitting";

GetAccountEffectivePrefs(accountName)

KillAccountSessions(accountName)

GetAccountACL(accountName [,authAccountName])

SetAccountACL(accountName,newACL [,authAccountName])

GetAccountACLRights(accountName ,authAccountName)

GetAccountLocation(accountName)
Example:
  if($path=$cli->GetAccountLocation('user')) {
       print "The account directory is $path\n";
     } else {
       die "Error: ".$cli->getErrMessage.", quitting";
  }

GetAccountPresence(accountName)


Group Administration Commands

ListGroups
Example:
  my $GroupsList = $cli->ListGroups('company.com')
     || die "Can't get the groups list: ".$cli->getErrMessage.", quitting";
  print "The group(s):\n";
  print "  $_\n" foreach(@$GroupsList);

CreateGroup(groupName, [ settings ])
Example:
  my %Settings=(
    RealName =>  "Sales staff",
    Members =>  ['john', 'susan', 'sales_box#mary', 'bill@partner.dom'],
    FinalDelivery => 'YES',
    RemoveToAndCc => 'YES',
    SetReplyTo => 'YES',
  );
  $cli->CreateGroup('sales',\%Settings) ||
    die "Error: ".$cli->getErrMessage.", quitting";

RenameGroup(oldGroupName,newGroupName)
Example:
  $cli->RenameGroup('sales','support')
        || die "Error: ".$cli->getErrMessage.", quitting";

DeleteGroup(oldGroupName)
Example:
  $cli->DeleteGroup('support')
        || die "Error: ".$cli->getErrMessage.", quitting";

GetGroup(groupName)
Example:
  if($Settings=$cli->GetGroup('sales')) {
    print "The settings are:\n";
    foreach (keys %$Settings) {
      my $data=@$Settings{$_};
      print "  $_ = ";
      if(ref ($data) eq 'ARRAY') {
        foreach my $member (@$data) {
          print "\'$member\' ";
        }
        print "\n";
      } else {
        print "\"$data\"\n";
      }
    }
  } else {
    die "Error: ".$cli->getErrMessage.", quitting";
  }

SetGroup(groupName, settings)
Example:
  $Settings=$cli->GetGroup('sales')
    ||  die "Error: ".$cli->getErrMessage.", quitting";
  @$Settings{'Members'}=[] unless(@$Settings{'Members'});
  my $Members=@$Settings{'Members'};
  push(@$Members,'sales_box#mary@company.com');
  $cli->SetGroup('sales',$Settings) ||
    die "Error: ".$cli->getErrMessage.", quitting";


Forwarder Administration Commands

ListForwarders
Example:
  my $ForwardersList = $cli->ListForwarders('company.com')
     || die "Can't get the forwarders list: ".$cli->getErrMessage.", quitting";
  print "The forwarder(s):\n";
  print "  $_\n" foreach(@$ForwardersList);

CreateForwarder(forwarderName,address)
Example:
  $cli->CreateForwarder('john','john@external.site.com')
        || die "Error: ".$cli->getErrMessage.", quitting";

RenameForwarder(forwarderName,newName)

DeleteForwarder(forwarderName)
Example:
  $cli->DeleteForwarder('john')
        || die "Error: ".$cli->getErrMessage.", quitting";

GetForwarder(forwarderName)
Example:
  if($data=$cli->GetForwarder('john')) {
    print "Address is \"$data\"\n";
  } else {
    die "Error: ".$cli->getErrMessage.", quitting";
  }

FindForwarders(domainName,forwarderAddress)


Named Task Administration Commands

ListDomainNamedTasks( [domain] )

ListAccountNamedTasks(account)

CreateNamedTask(taskName,account)

RenameNamedTask(taskName,newName)

DeleteNamedTask(taskName)

GetNamedTask(taskName)

UpdateNamedTask(taskName,settings)


Domain Administration Commands

ListDomains
Example:
  my $DomainList = $cli->ListDomains()
     || die "Can't get the domain list: ".$cli->getErrMessage.", quitting";
  print "The domain(s):\n";
  print "  $_\n" foreach(@$DomainList);

MainDomainName
Example:
  my $MainDomainName=$cli->MainDomainName()
     || die "Error: ".$cli->getErrMessage.", quitting";
  print "The main domain name is $MainDomainName\n";

GetDomainSettings( [domainName] )
Example:
  if($Settings=$cli->GetDomainSettings) {
    print "The domain settings are:\n";
      print "  $_ = \"@$Settings{$_}\"\n" foreach (keys %$Settings);
  } else {
    die "Error: ".$cli->getErrMessage.", quitting" if(!$cli->isSuccess);
  }

GetDomainEffectiveSettings( [domainName] )

UpdateDomainSettings(domain => domainName, settings => newSettings)
Example:
  $cli->UpdateDomainSettings(domain => 'www.company.com',
                     settings => { WebUserCache => "NO" })
        || die "Error: ".$cli->getErrMessage.", quitting";

SetDomainSettings(domain => domainName, settings => newSettings)

CreateDomainStorage($path[,'SHARED'])
Example:
$cli->CreateDomainStorage("Volume1",'SHARED')
 || die "Can't create mount point: ".$cli->getErrMessage.", quitting";

ListDomainStorage(['SHARED'])
Example:
my $data=$cli->ListDomainStorage('SHARED');
die "Error: ".$cli->getErrMessage.", quitting" if(!$cli->isSuccess);
print "mount point: $_\n" foreach(@$data);

CreateDomain(domainName [, settings [,$path[,'SHARED']]])
Example:
  $cli->CreateDomain('mail.company.com',{AutoSignup => 'YES'})
        || die "Error: ".$cli->getErrMessage.", quitting";

CreateDirectoryDomain(domainName, [ settings ])

RenameDomain(oldDomainName,newDomainName)
Example:
  $cli->RenameDomain('old.company.com','new.company.com')
        || die "Error: ".$cli->getErrMessage.", quitting";

DeleteDomain(domainName, [force])
Example:
  $cli->DeleteDomain('test.company.com',1)
        || die "Error: ".$cli->getErrMessage.", quitting";

SuspendDomain(domainName)

ResumeDomain(domainName)

CreateAccountStorage(domainName,path)

ListAccountStorage(domainName)
Example:
$cli->CreateDomainStorage('test.company.com',"my_dir")
 || die "Can't create mount point: ".$cli->getErrMessage.", quitting";

my $data=$cli->ListAccountStorage('test.company.com');
die "Error: ".$cli->getErrMessage.", quitting" if(!$cli->isSuccess);
print "mount point: $_\n" foreach(@$data);

GetDomainAliases(domainName)
Example:
  if($Aliases=$cli->GetDomainAliases('company.com')) {
    print "The aliases are:\n";
    print "  $_\n" foreach (@$Aliases);
  } else {
    ($cli->isSuccess) ? print "No aliases\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

SetDomainAliases(domainName, newAliases)
Example:
  my @Aliases=(
    'mail.company.com',
    'smtp.company.com'
  );
  $cli->SetDomainAliases('company.com',\@Aliases)
        || die "Error: ".$cli->getErrMessage.", quitting";

GetDomainMailRules(domainName)

SetDomainMailRules(domainName, newRules)

GetDomainSignalRules(domainName)

SetDomainSignalRules(domainName, newRules)

ListAdminDomains( [domainName] )
Example:
  my $DomainList = $cli->ListAdminDomains('company.com')
     || die "Can't get the list of admin domains: ".$cli->getErrMessage.", quitting";
  print "The admin domain(s):\n";
  print "  $_\n" foreach(@$DomainList);

InsertDirectoryRecords( [domainName] )

DeleteDirectoryRecords( [domainName] )

GetServerTrustedCerts()

SetServerTrustedCerts(newCertificates)

GetClusterTrustedCerts()

SetClusterTrustedCerts(newCertificates)

GetDirectoryIntegration
Example:
  if($Settings=$cli->GetDirectoryIntegration) {
    print "The directory integration settings are:\n";
    foreach (keys %$Settings) {
      my $data=@$Settings{$_};
      print "  $_ = ";
      if(ref ($data) eq 'ARRAY') {
        print join(",",@$data)."\n";    
      }elsif(ref($data) eq 'HASH') {
        print "{";
        print "$_=@$data{$_};" foreach (keys %$data);
        print "}\n";    
      } else {
        print "\"$data\"\n";
      }
    }
  } else {
    die "Error: ".$cli->getErrMessage.", quitting" if(!$cli->isSuccess);
  }

SetDirectoryIntegration(newSettings)
Example:
  $Settings=$cli->GetDirectoryIntegration()
    || die "Error: ".$cli->getErrMessage.", quitting";
  my $Attributes=@$Settings{'CustomAttributes'};
  push(@$Attributes,"MyAttr");
  $cli->SetDirectoryIntegration($Settings)
    || die "Error: ".$cli->getErrMessage.", quitting";

GetClusterDirectoryIntegration

SetClusterDirectoryIntegration(newSettings)

GetDomainDefaults
Example:
  if($Defaults=$cli->GetDomainDefaults()) {
    print "The default domain settings are:\n";
    print "  $_ = \"@$Defaults{$_}\"\n" foreach (keys %$Defaults);
  } else {
    ($cli->isSuccess) ? print "No default domain settings.\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

UpdateDomainDefaults(newSettings)
Example:
  $cli->UpdateDomainDefaults({MailToUnknown => "Rejected"})
        || die "Error: ".$cli->getErrMessage.", quitting";

SetDomainDefaults(newSettings)

GetClusterDomainDefaults

UpdateClusterDomainDefaults(newSettings)

SetClusterDomainDefaults(newSettings)

GetServerAccountDefaults
Example:
  if($Defaults=$cli->GetServerAccountDefaults()) {
    print "The default settings are:\n";
    print "  $_ = \"@$Defaults{$_}\"\n" foreach (keys %$Defaults);
  } else {
    ($cli->isSuccess) ? print "No default settings.\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

UpdateServerAccountDefaults(newSettings)
Example:
  $cli->UpdateServerAccountDefaults({AccessModes => "All"})
        || die "Error: ".$cli->getErrMessage.", quitting";

SetServerAccountDefaults(newSettings)

GetClusterAccountDefaults

SetClusterAccountDefaults(newSettings)

UpdateClusterAccountDefaults(newSettings)

GetServerAccountPrefs

UpdateServerAccountPrefs(newSettings)

SetServerAccountPrefs(newSettings)

GetClusterAccountPrefs

UpdateClusterAccountPrefs(newSettings)

SetClusterAccountPrefs(newSettings)

GetDomainLocation(domainName)
Example:
  if($path=$cli->GetDomainLocation('company.com')) {
       print "The domain directory is /var/CommuniGate/$path\n";
     } else {
       die "Error: ".$cli->getErrMessage.", quitting";
  }

ListServerTelnums (limit[,filter] )

ListClusterTelnums (limit[,filter] )

GetAccountDefaults( [domainName ] )
Example:
  if($Defaults=$cli->GetAccountDefaults) {
    print "The account defaults are:\n";
    print "  $_ = \"@$Defaults{$_}\"\n" foreach (keys %$Defaults);
  } else {
    die "Error: ".$cli->getErrMessage.", quitting" if(!$cli->isSuccess);
  }

UpdateAccountDefaults( domain => domainName, settings => newSettings)
Example:
  $cli->UpdateAccountDefaults(domain => 'company.com',
                              settings => {MaxAccountSize => '100K'})
        || die "Error: ".$cli->getErrMessage.", quitting";

SetAccountDefaults( domain => domainName, settings => newSettings)

GetAccountDefaultPrefs( [domainName ] )
Example:
  if($Defaults=$cli->GetAccountDefaultPrefs()) {
    print "The WebUser defaults are:\n";
    print "  $_ = \"@$Defaults{$_}\"\n" foreach (keys %$Defaults);
  } else {
    die "Error: ".$cli->getErrMessage.", quitting" if(!$cli->isSuccess);
  }

SetAccountDefaultPrefs( domain => domainName, settings => newSettings)

UpdateAccountDefaultPrefs( domain => domainName, settings => newSettings)
Example:
  my %Settings=(
    Charset =>  'ISO-8859-1',
    Fields =>  [ qw(From Sender Subject Date To Cc) ]
  );

  $cli->UpdateAccountDefaultPrefs(settings=>\%Settings)
        || die "Error: ".$cli->getErrMessage.", quitting";

GetAccountTemplate( [domainName] )
Example:
  if($Template=$cli->GetAccountTemplate) {
    print "The template account settings are:\n";
      print "  $_ = \"@$Template{$_}\"\n" foreach (keys %$Template);
  } else {
    die "Error: ".$cli->getErrMessage.", quitting" if(!$cli->isSuccess);
  }

UpdateAccountTemplate(domain => domainName, settings => newSettings);
Example:
  $cli->UpdateAccountTemplate(domain => 'company.com',
                         settings => { RealName => 'Unnamed',Password => ''})
        || die "Error: ".$cli->getErrMessage.", quitting";

SetAccountTemplate(domain => domainName, settings => newSettings);


Mailbox Administration Commands

ListMailboxes(accountName => account,[ filter => '*',] [authAccountName => extAccount]);
Example:
  my $Boxes= $cli->ListMailboxes(accountName=>'john',filter=>'INBOX*')
     || die "Error: ".$cli->getErrMessage.", quitting";

  foreach (sort keys %$Boxes) {
    print "$_\n";
    my $data=@$Boxes{$_};
    if(ref $data eq 'ARRAY') {
      $data=@$data[0];
    }   
    if(ref $data eq 'HASH') {
      foreach (keys %$data) {
        print "  $_ = @$data{$_}\n";
      }
    }
  }

CreateMailbox(accountName,mailboxName[,authAccountName]);
Example:
  $cli->CreateMailbox('john','SharedItems') 
    || die "Error: ".$cli->getErrMessage.", quitting";

RenameMailbox(accountName,oldMailboxName,newMailboxName[,authAccountName]);
RenameMailboxes(accountName,oldMailboxName,newMailboxName[,authAccountName]);
Example:
  $cli->RenameMailbox('john','myItems','SharedItems') 
    || die "Error: ".$cli->getErrMessage.", quitting";

DeleteMailbox(accountName,mailboxName[,authAccountName]);
DeleteMailboxes(accountName,mailboxName[,authAccountName]);
Example:
  $cli->DeleteMailbox('john','SharedItems') 
    || die "Error: ".$cli->getErrMessage.", quitting";

GetMailboxInfo(accountName,mailboxName[,authAccountName]);
Example:
  my $info = $cli->GetMailboxInfo('john','SharedItems')
           || die "Error: ".$cli->getErrMessage.", quitting";

  foreach (sort keys %$info) {
    my $data=@$info{$_};
    if(ref $data eq 'HASH') {
      print "  $_:\n";
      foreach (keys %$data) {
        print "    $_ = @$data{$_}\n";
      }
    } else {
      print "  $_ = @$info{$_}\n";
    }
  }

GetMailboxACL(accountName,mailboxName[,authAccountName]);
Example:
  my $acl = $cli->GetMailboxACL('john','SharedItems')
           || die "Error: ".$cli->getErrMessage.", quitting";
  foreach (keys %$acl) {
    print "  $_ = @$acl{$_}\n";
  }

SetMailboxACL(accountName,mailboxName,newACL[,authAccountName]);
Example:
  my %newACL=(
    "boss" =>  'ipcda',
    "+susan" =>  'lrsw',
  );
  $cli->SetMailboxACL('john','SharedItems',\%newACL)
    || die "Error: ".$cli->getErrMessage.", quitting";

GetMailboxRights(accountName,mailboxName,authAccountName);
Example:
  if($Rights= $cli->GetMailboxRights('john','SharedItems','boss')) {
    print "The rights = $Rights\n";
  } else {
    ($cli->isSuccess) ? print "The boss account has no rights to access this mailbox\n"
                       : die "Error: ".$cli->getErrMessage.", quitting";
  }

SetMailboxClass(accountName,mailboxName,class [,authAccountName]);
Example:
  $cli->SetMailboxClass('john','Calendar','IPF.Appointment')
    || die "Error: ".$cli->getErrMessage.", quitting";

GetMailboxSubscription(accountName);
Example:
  if($Subscription= $cli->GetMailboxSubscription('john')) {
    print "The subscription: ".join(",",@$Subscription)."\n";
  } else {
    ($cli->isSuccess) ? print "This account has no subscribed mailboxes\n"
                       : die "Error: ".$cli->getErrMessage.", quitting";
  }

SetMailboxSubscription(accountName,newSubscription);
Example:
  $Subscription= $cli->GetMailboxSubscription('john')
    || die "Error: ".$cli->getErrMessage.", quitting";
  push(@$Subscription,'~user@company.com/INBOX');
  $cli->SetMailboxSubscription('john',$Subscription)
    || die "Error: ".$cli->getErrMessage.", quitting"; 

GetMailboxAliases(accountName);
Example:
  if($Aliases=$cli->GetMailboxAliases('john')) {
    print "The aliases are:\n";
    foreach (keys %$Aliases) {
      print " $_ = @$Aliases{$_}\n";
    }
  } else {
     ($cli->isSuccess) ? print "No aliases\n"
       : die "Error: ".$cli->getErrMessage.", quitting";
  }

SetMailboxAliases(accountName,newAliases);
Example:
  $Aliases=$cli->GetMailboxAliases('john')
      || die "Error: ".$cli->getErrMessage.", quitting";
  @$Aliases{'ExternalBox'}='~user@company.com/INBOX';
  $cli->SetMailboxAliases('john',$Aliases)
      || die "Error: ".$cli->getErrMessage.", quitting";


Alert Administration Commands

GetDomainAlerts( [domainName] )
Example:
  $Alerts=$cli->GetDomainAlerts('company.com')
          || die "Error: ".$cli->getErrMessage.", quitting";

  foreach(keys %$Alerts) {
    my ($xx,$yr,$mn,$dy,$hr,$min,$sec)=split(/(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/);
    print "$dy.$mn.$yr $hr:$min:$sec - @$Alerts{$_}\n";
  }

SetDomainAlerts(domainName,alerts)
Example:
  my %Alerts =(
    '19991225235959' => 'Merry Christmas!',
    '20000101000000' => 'Happy New Year!',
  );
  $cli->SetDomainAlerts('company.com',\%Alerts)
        || die "Error: ".$cli->getErrMessage.", quitting";

PostDomainAlert(domainName,alert)
Example:
   $cli->PostDomainAlert('company.com',"We're shutting down in 10 minutes!")
        || die "Error: ".$cli->getErrMessage.", quitting";

RemoveDomainAlert(domainName,timeStamp)
Example:
   $cli->PostDomainAlert('company.com','20000101000000')
        || die "Can't remove the NewYear alert: ".$cli->getErrMessage.", quitting";

GetAccountAlerts(accountName)

SetAccountAlerts(accountName,alerts)

PostAccountAlert(accountName,alert)

RemoveAccountAlert(accountName,timeStamp)

GetServerAlerts()

SetServerAlerts(alerts)

PostServerAlert(alert)

RemoveServerAlert(timeStamp)

GetClusterAlerts()

SetClusterAlerts(alerts)

PostClusterAlert(alert)

RemoveClusterAlert(timeStamp)


File Storage Administration

ReadStorageFile(accountName,fileName [,position,sliceSize[,authAccountName]])
Example:
  $data=$cli->ReadStorageFile('john','logo.gif')
   || die "Error: ".$cli->getErrMessage.", quitting";
  print "File data=$data->[0]\n";
  print "File modification date: @$data[1] size: @$data[2]\n";

WriteStorageFile(accountName,fileName,data [,position[,authAccountName]]

RenameStorageFile(accountName,oldFileName,newFileName[,authAccountName])
Example:
  $cli->RenameStorageFile('john','StalkerLogo.gif','logo.gif')
   || die "Error: ".$cli->getErrMessage.", quitting";

DeleteStorageFile(accountName,fileName[,authAccountName])
Example:
  $cli->DeleteStorageFile('john','logo.gif')
   || die "Error: ".$cli->getErrMessage.", quitting";

ListStorageFiles(accountName [,filePath[,authAccountName]])
Example:
  if($Files=$cli->ListStorageFiles('john')) {
    print "The files are:\n";
    print "  $_\n" foreach (keys %$Files);
  } else {
    ($cli->isSuccess) ? print "No web files.\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

GetStorageFileInfo(accountName[,filePath[,authAccountName])
Example:
  $data=$cli->GetStorageFileInfo('john')
   || die "Error: ".$cli->getErrMessage.", quitting";
  print "There are $data->[1] files $data->[0] bytes total\n";

ReadStorageFileAttr(accountName,fileName[,attributes[,authAccountName]])

UpdateStorageFileAttr(accountName,fileName,attributes[,authAccountName])

GetFileSubscription($accountName)

SetFileSubscription($accountName, \@newSubscription)


Mailing Lists Administration Commands

ListLists( [domainName] )
Example:
  if($Lists=$cli->ListLists('company.com')) {
    print "The lists are:\n";
    print "  $_\n" foreach (@$Lists);
  } else {
    ($cli->isSuccess) ? print "No lists.\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

GetDomainLists( [domainName] )
Example:
  $Lists=$cli->GetDomainLists('company.com')) 
    || die "Error: ".$cli->getErrMessage.", quitting";
    print "The lists are:\n";
    foreach (keys %$Lists) {
      my $nSubs=@$Lists{$_};
      $nSubs='unknown' if $nSubs==-1;
      print " $_ ($nSubs)\n";
    }

GetAccountLists(accountName)
Example:
  $Lists=$cli->GetAccountLists('listmaster')) 
    || die "Error: ".$cli->getErrMessage.", quitting";
    print "The lists are:\n";
    foreach (keys %$Lists) {
      my $nSubs=@$Lists{$_};
      $nSubs='unknown' if $nSubs==-1;
      print " $_ ($nSubs)\n";
    }

CreateList(listName,accountName)
Example:
  $cli->CreateList('TestList@company.com','john')
        || die "Error: ".$cli->getErrMessage.", quitting";

RenameList(listName,newName)
Example:
  $cli->RenameList('TestList@company.com','InfoList')
        || die "Error: ".$cli->getErrMessage.", quitting";

DeleteList(listName)
Example:
  $cli->DeleteList('InfoList@company.com')
        || die "Error: ".$cli->getErrMessage.", quitting";

GetList(listName)
Example:
  if($Settings=$cli->GetList('TestList@company.com')) {
    print "The list settings are:\n";
    print "  $_ = \"@$Settings{$_}\"\n" foreach (keys %$Settings);
  } else {
    ($cli->isSuccess) ? print "Nothing...\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

UpdateList(listName,newSettings)
Example:
  $cli->UpdateList('TestList@company.com',{RealName => "the test list"})
        || die "Error: ".$cli->getErrMessage.", quitting";

List(listName, operation, subscriber, [options])
Example:
  $cli->List("myList", 'subscribe',
             '"John Smith" <john@company.com>',
             'silently','confirm')
        || die "Can't subscribe John: ".$cli->getErrMessage.", quitting";

ListSubscribers(listName [, filter[, limit]])
Example:
  my $subscribers=$cli->ListSubscribers("myList", '', 10)
        || die "Can't list subscribers: ".$cli->getErrMessage.", quitting";
  print "  $_\n" foreach(@$subscribers);

GetSubscriberInfo(listName,subscriberAddress)
Example:
if($Infos=$cli->GetSubscriberInfo('TestList@company.com','user@domain.com')) {
  print "The subscriber info:\n";
  foreach (keys %$Infos) {
    print "  $_ = \"@$Infos{$_}\"\n";
  }
} else {
  die "Error: ".$cli->getErrMessage.", quitting";
}

SetPostingMode(listName,subscriberAddress, mode)
Example:
  $cli->SetPostingMode('TestList@company.com','user@domain.com',"UNMODERATED")
        || die "Error: ".$cli->getErrMessage.", quitting";

ProcessBounce(listName,subscriberAddress [,fatal] )
Example:
  $cli->ProcessBounce('TestList@company.com','user@domain.com',0)
        || die "Error: ".$cli->getErrMessage.", quitting";


Web Skins Administration

ListDomainSkins( [domainName] )
Example:
  my $Files= $cli->ListDomainSkins('company.com')
     || die "Error: ".$cli->getErrMessage.", quitting";
  print (($_ eq '') ? "Basic skin\n" : "$_\n") foreach (@$Files);

CreateDomainSkin(domainName,skinName)
Example:
  $cli->CreateDomainSkin('company.com',"mySkin1")
     || die "Error: ".$cli->getErrMessage.", quitting";

RenameDomainSkin(domainName,oldSkinName,newSkinName)
Example:
  $cli->RenameDomainSkin('company.com',"mySkin1","mySkin")
    || die "Error: ".$cli->getErrMessage.", quitting";

DeleteDomainSkin(domainName,skinName)

ListDomainSkinFiles(domainName,skinName)
Example:
  my $Files= $cli->ListDomainSkinFiles('company.com',"MySkin")
            || die "Error: ".$cli->getErrMessage.", quitting";
  foreach (sort keys %$Files) {
    print "$_\n";
    my $data=@$Files{$_};
    if(ref $data eq 'HASH') {
      foreach (keys %$data) {
        print "  $_ = @$data{$_}\n";
      }
    }
  }

ReadDomainSkinFile(domainName,skinName,fileName)
Example:
  my $Data = $cli->ReadDomainSkinFile('company.com',"MySkin",'logo.gif')
            || die "Error: ".$cli->getErrMessage.", quitting";
  print "Date (YyyyMmDdHhMmSs): @$Data[1]\n";
  print "Base64 data: @$Data[0]\n";

StoreDomainSkinFile(domainName,skinName,fileName,base64data)
Example:
  use MIME::Base64;

  $cli->StoreDomainSkinFile('company.com',"MySkin",'logo.gif',encode_base64($data, ""))
            || die "Error: ".$cli->getErrMessage.", quitting";

DeleteDomainSkinFile(domainName,skinName,fileName)

ListServerSkins
Example:
  my $Files= $cli->ListServerSkins()
     || die "Error: ".$cli->getErrMessage.", quitting";
  print (($_ eq '') ? "Basic skin\n" : "$_\n") foreach (@$Files);

CreateServerSkin(skinName)

RenameServerSkin(oldSkinName,newSkinName)

DeleteServerSkin(skinName)

ListServerSkinFiles(skinName)

ReadServerSkinFile(skinName,fileName)

StoreServerSkinFile(skinName,fileName,base64data)

DeleteServerSkinFile(skinName,fileName)

ListClusterSkins

CreateClusterSkin(skinName)

RenameClusterSkin(oldSkinName,newSkinName)

DeleteClusterSkin(skinName)

ListClusterSkinFiles(skinName)

ReadClusterSkinFile(skinName,fileName)

StoreClusterSkinFile(skinName,fileName,base64data)

DeleteClusterSkinFile(skinName,fileName)

ListStockSkinFiles(skinName)

ReadStockSkinFile(skinName,fileName)


Web Interface Tuning Commands

ListWebUserInterface( [domainName] )
Example:
  my $Files= $cli->ListWebUserInterface('company.com')
     || die "Error: ".$cli->getErrMessage.", quitting";

  foreach (sort keys %$Files) {
    print "$_\n";
    my $data=@$Files{$_};
    if(ref $data eq 'HASH') {
      foreach (keys %$data) {
        print "  $_ = @$data{$_}\n";
      }
    }
  }

GetWebUserInterface(domainName,fileName)
Example:
  my $FileData= $cli->GetWebUserInterface('*','default.html')
    || die "Error: ".$cli->getErrMessage.", quitting";
  print $FileData;

PutWebUserInterface(domainName,fileName,fileBase64Data)

DeleteWebUserInterface(domainName,fileName)
Example:
  $cli->DeleteWebUserInterface('*','default.html')
    || die "Error: ".$cli->getErrMessage.", quitting";

ClearWebUserCache( [domainName] )
Example:
  $cli->ClearWebUserCache('company.com')
    || die "Error: ".$cli->getErrMessage.", quitting";


Web Interface Integration Commands

CreateWebUserSession( accountName, IP_ADDRESS [, WML[,skinName[,origAddress]]] )
Example:
  my $sessionID=$cli->CreateWebUserSession('user','127.0.0.1',0)
     || die "Error: ".$cli->getErrMessage.", quitting";
  print "$sessionID\n";

CreateXIMSSSession( accountName, IP_ADDRESS [,origAddress] )

FindAccountSession( accountName [,IP_ADDRESS,proxiedAddress,protocol,transport,client] )

ListAccountSessions( accountName [,IP_ADDRESS,proxiedAddress,protocol,transport,client] )
Example:
  my $data=$cli->ListAccountSessions('user')
    || die "Error: ".$cli->getErrMessage;
  print "The sessions are:\n";
  print "$_\n" foreach(@$data);

GetSession( sessionID [,domainName] )
Example:
  my $data=$cli->GetSession('1-pIX3cdbUQIGg79Nx03b4')
    || die "Error: ".$cli->getErrMessage;
  print "The sessions data are: ".$cli->printWords($data)."\n";

KillSession( sessionID [,domainName] )


Real-Time Application Administration Commands

CreateDomainPBX( domainName [,language] )
Example:
  $cli->CreateDomainPBX('company.com',"japanese")
     || die "Error: ".$cli->getErrMessage.", quitting";

DeleteDomainPBX( domainName ,language )
Example:
  $cli->DeleteDomainPBX('company.com',"japanese")
     || die "Error: ".$cli->getErrMessage.", quitting";

ListDomainPBXFiles( domainName [,language] )
Example:
  my $Files= $cli->ListDomainPBXFiles('company.com','japanese')
     || die "Error: ".$cli->getErrMessage.", quitting";

  foreach (sort keys %$Files) {
    print "$_\n";
    my $data=@$Files{$_};
    if(ref $data eq 'HASH') {
      foreach (keys %$data) {
        print "  $_ = @$data{$_}\n";
      }
    }
  }

ReadDomainPBXFile( domainName , fileName )

Note:To retrieve a file from a national subset, specify the name as language/fileName.

StoreDomainPBXFile( domainName , fileName, base64data )
Example:
  use MIME::Base64;

  $cli->StoreDomainPBXFile('company.com','sound.wav',encode_base64($data, ""))
            || die "Error: ".$cli->getErrMessage.", quitting";

DeleteDomainPBXFile( domainName , fileName )

CreateServerPBX( language )

DeleteServerPBX( language )

ListServerPBXFiles( [language] )

ReadServerPBXFile( fileName )

StoreServerPBXFile( fileName, base64data )

DeleteServerPBXFile( fileName )

CreateClusterPBX( language )

DeleteClusterPBX( language )

ListClusterPBXFiles( [language] )

ReadClusterPBXFile( fileName )

StoreClusterPBXFile( fileName, base64data )

DeleteClusterPBXFile( fileName )

ListStockPBXFiles( [language] )

ReadStockPBXFile( fileName )


Real-Time Application Control Commands

StartPBXTask( account, program [,entryName,param] )

SendTaskEvent( taskID, eventName [,param] )

KillNode( taskID )

ReadNodeStatus( taskID )


Account Services Commands

RemoveAccountSubset(accountName,subsetName)
Example:
  
  $cli->RemoveAccountSubset('user','RepliedAddresses')
    || die "Can't remove: ".$cli->getErrMessage;

Balance(accountName,\%parameters)
Example:
  
  my $data=$cli->Balance('user',{ op=>'credit', balance=>'newBalance', amount=>'100' } )
    || die "Can't credit: ".$cli->getErrMessage;

Roster(accountName,\%parameters)
Example:
  
  my $data=$cli->Roster('user',{ what=>'List' } )
    || die "Can't get buddies list: ".$cli->getErrMessage;
  print "The buddies are:\n";
  foreach (sort keys %$data) {
    print "$_ $data->{$_}->{RealName}\n";
  }

Dataset(accountName,\%parameters)


Server Setting Commands

ListModules()

GetModule(moduleName)
Example:
  if($Settings=$cli->GetModule('SMTP')) {
    print "The SMTP settings are:\n";
    print "  $_ = \"@$Settings{$_}\"\n" foreach (keys %$Settings);
  } else {
    ($cli->isSuccess) ? print "Nothing...\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

UpdateModule(moduleName,newSettings)
Example:
  $cli->UpdateModule("SMTP",{LogLevel => 3})
        || die "Error: ".$cli->getErrMessage.", quitting";

SetModule(moduleName,newSettings)

GetQueueSettings()

SetQueueSettings(newSettings)

GetSignalSettings()

SetSignalSettings(newSettings)

GetMediaServerSettings()

SetMediaServerSettings(newSettings)

GetSessionSettings()

SetSessionSettings(newSettings)

GetClusterSettings()

SetClusterSettings(newSettings)

GetLogSettings()

UpdateLogSettings(newSettings)

GetLANIPs

GetBlacklistedIPs
Example:
  if($Data = $cli->GetBlacklistedIPs()) {
    $Data =~ s/\\e/\n/g;
    print "$Data\n";
  } else {
    ($cli->isSuccess) ? print "No addresses entered\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

GetClientIPs

GetWhiteHoleIPs

GetNATedIPs

GetNATSiteIPs

GetDebugIPs

GetDeniedIPs

GetNetwork

GetDNRSettings

GetBanned

SetLANIPs(addresses)

SetBlacklistedIPs(addresses)
Example:
  $cli->SetBlacklistedIPs('11.22.33.44\e33.44.55.66')
        || die "Error: ".$cli->getErrMessage.", quitting";

SetClientIPs(addresses)

SetWhiteHoleIPs(addresses)

SetNATedIPs(settings)

SetNATSiteIPs(settings)

SetDebugIPs(settings)

SetDeniedIPs(settings)

SetNetwork(settings)

SetDNRSettings(settings)

SetBanned(settings)

GetClusterLANIPs

GetClusterBlacklistedIPs

GetClusterClientIPs

GetClusterWhiteHoleIPs

GetClusterNATedIPs

GetClusterNATSiteIPs

GetClusterDebugIPs

GetClusterDeniedIPs

GetClusterNetwork

GetClusterBanned

SetClusterLANIPs(addresses)

SetClusterBlacklistedIPs(addresses)

SetClusterClientIPs(addresses)

SetClusterWhiteHoleIPs(addresses)

SetClusterNATedIPs(addresses)

SetClusterNATSiteIPs(addresses)

SetClusterDebugIPs(addresses)

SetClusterDeniedIPs(addresses)

SetClusterNetwork(settings)

GetServerMailRules()
Example:
  my $Rules=$cli->GetServerMailRules()
            || die "Error: ".$cli->getErrMessage.", quitting";

  foreach my $Rule (@$Rules) {
    my $conditions=$Rule->[2],$actions=$Rule->[3];
    print "\nName='$Rule->[1]' Priority=$Rule->[0]\n";
    print "  If\n  ";
    foreach my $cond (@$conditions) {
      print " $_ " foreach (@$cond);
      print "\n  ";
    }
    print "Then\n  ";
    foreach my $actn (@$actions) {
      print " $_ " foreach (@$actn);
      print "\n  ";
    }
  }

SetServerMailRules(newRules)
Example:
  my @Rules =(
  [ 5,'Size Limit',
    [ ['Message Size', 'greater than', '10M] ],
    [ ['Reject with', 'Your message is too big!'],
    ]
  ],
  [ 5,'Save Outgoing',
    [ ['Return-Path', 'is', '<*@mydomain.com>] ],
    [ ['Store in', '~security/outgoing'],
    ]
  ]
  
  );

  $cli->SetServerMailRules(\@Rules)
        || die "Error: ".$cli->getErrMessage.", quitting";

GetClusterMailRules()

SetClusterMailRules(newRules)

GetClusterSignalRules()

SetClusterSignalRules(newRules)

GetServerSettings()

UpdateServerSettings(newRules)

RefreshOSData
Example:
  $cli->RefreshOSData()
           || die "Error: ".$cli->getErrMessage.", quitting";

GetRouterTable
Example:
  my $routerData=$cli->GetRouterTable()
           || die "Error: ".$cli->getErrMessage.", quitting";
  $routerData=~s/\\e/\n/g;
  print "$routerData\n";

SetRouterTable(data)
Example:
  my $routerData=$cli->GetRouterTable()
           || die "Error: ".$cli->getErrMessage.", quitting";

  $routerData.='\e' if(substr($routerData,-2,2) ne '\e');
  $routerData.='<addr1>=addr1@domain.com\e';
  $cli->SetRouterTable($routerData)
           || die "Error: ".$cli->getErrMessage.", quitting";

GetRouterSettings
Example:
if($Settings=$cli->GetRouterSettings()) {
  print "The settings are:\n";
  foreach (keys %$Settings) {
    print "  $_ = \"@$Settings{$_}\"\n";
  }
} else {
  die "Error: ".$cli->getErrMessage.", quitting";
}

SetRouterSettings(settings)

GetClusterRouterTable

SetClusterRouterTable(data)

GetClusterRouterSettings()

SetClusterRouterSettings(settings)

GetServerIntercept

SetServerIntercept(data)

GetClusterIntercept

SetClusterIntercept(data)

Route(address[,'mail|access|signal'])
Example:
  my $data=$cli->Route('user@domain.net','mail')
           || die "Error: ".$cli->getErrMessage.", quitting";
  print "Module  =$data->[0]\n";
  print "Host    =$data->[1]\n";
  print "Address =$data->[2]\n";

GetIPState(address[,'TEMP'])
Example:
  my $data=$cli->GetIPState('127.0.0.1','TEMP');
           || die "Error: ".$cli->getErrMessage.", quitting";
  print "The state is: '$data'\n";


Monitoring Commands

GetStatElement(elemName)
Example:
  my $data=$cli->GetStatElement('1.3.6.1.4.1.5678.2.1.1.1.1.10')
           || die "Error: ".$cli->getErrMessage.", quitting";
  print "Incoming SMTP messages: $data\n";

GetNextStatName(elemName)
Example:
  my $data=$cli->GetNextStatName('1.3.6.1.4.1.5678.2.1.1.1.1.10')
           || die "Error: ".$cli->getErrMessage.", quitting";
  print "Next name is: $data\n";

SetStatElement(elemName,command [,value])

GetDialogID(signalDialogID)

Shutdown
Example:
  $cli->Shutdown;


Statistics Commands

GetAccountStat(account[,key])
Example:
  
  if($nMessages=$cli->GetAccountStat('user@company.com','MessagesReceived')) {
    my $nBytes=$cli->GetAccountStat('user@company.com','BytesReceived');
    print "The user had received $nMessages messages $nBytes bytes total.\n";
  } else {
    ($cli->isSuccess) ? print "The user had received no messages.\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

ResetAccountStat(account[,key])
Example:
  
  $cli->ResetAccountStat('user@company.com','MessagesReceived')
    || die "Error: ".$cli->getErrMessage;

GetDomainStat(domain[,key])
Example:
  
  if($nMessages=$cli->GetDomainStat('company.com','MessagesReceived')) {
    my $nBytes=$cli->GetDomainStat('company.com','BytesReceived');
    print "The user had received $nMessages messages $nBytes bytes total.\n";
  } else {
    ($cli->isSuccess) ? print "The domain had received no messages.\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

ResetDomainStat(domain[,key])
Example:
  
  $cli->ResetDomainStat('*')
    || die "Error: ".$cli->getErrMessage;


Directory Administration Commands

CreateDirectoryUnit(unitName,mountPoint,[shared,[remote]])

RelocateDirectoryUnit(unitName,newMountPoint,[shared])

DeleteDirectoryUnit(unitName,[shared])

GetDirectoryUnit(unitName,[shared])

SetDirectoryUnit(unitName,newSettings,[shared])

GetDirectoryAccessRights([shared])

SetDirectoryAccessRights(newRights,[shared])


Miscellaneous Commands

ListCLICommands
Example:
  
  my $data=$cli->ListCLICommands()
    || die "Error: ".$cli->getErrMessage;
  print "The commands are: ".join(', ',@$data)."\n";

Noop

Echo(object)
Example:
    my $data=$cli->Echo( { a=>'b', c=>['d','e'], } )
    || die "Error: ".$cli->getErrMessage;
  print "The object is: ".$cli->printWords($data)."\n";

GetVersion
Example:
  my $data=$cli->GetVersion()
    || die "Error: ".$cli->getErrMessage;
  print "The version is: ".$data."\n";

GetCurrentTime
Example:
  
  my $data=$cli->GetCurrentTime()
    || die "Error: ".$cli->getErrMessage;
  print "The time is: ".$data."\n";

SetLogAll(ON | OFF)

DumpAllObjects

TestLoop(seconds)
Example:
  
  my $data=$cli->TestLoop(5)
    || die "Error: ".$cli->getErrMessage;
  print "The speed is ".$data." loops per second\n";

SetTrace(facility [,ON | OFF])
Example:
  
  $cli->SetTrace(FileIO,"ON")
    || die "Error: ".$cli->getErrMessage;

WriteLog(level,message)
Example:
  
  $cli->WriteLog(2,'my test log message')
    || die "Can't write to log: ".$cli->getErrMessage;

ReleaseSMTPQueue(queueName)
Example:
  
  $cli->ReleaseSMTPQueue('mail.domain.com')
    || die "Can't release queue: ".$cli->getErrMessage;

RejectQueueMessage(messageID [,errorText])
Example:
  
  $cli->RejectQueueMessage('123456','your message is rejected')
    || die "Can't reject message: ".$cli->getErrMessage;

RejectQueueMessages(account [,errorText])
Example:
  
  $cli->RejectQueueMessages('user@company.com','NONDN')
    || die "Can't reject messages: ".$cli->getErrMessage;

GetMessageQueueInfo(moduleName,queueName)

GetCurrentController
Example:
  
  my $data=$cli->GetCurrentController()
    || die "Can't learn where's the cluster controller: ".$cli->getErrMessage;
  print "The Controller is $data\n";

GetTempClientIPs
Example:
  
  if($data=$cli->GetTempClientIPs()) {
     print "The temp client IPs are: $data\n";
  } else {
    ($cli->isSuccess) ? print "Currently there're no temp client IPs.\n"
                      : die "Error: ".$cli->getErrMessage.", quitting";
  }

TempBlacklistIP(IP, timeout)
Example:
$cli->TempBlacklistIP("111.111.1.1",0);

GetTempBlacklistedIPs

SetTempBlacklistedIPs(IPs)
Example:
  my $data=$cli->GetTempBlacklistedIPs();  
  if($cli->isSuccess) {
    $data .="\\e11.22.33.44-100\\e22.33.44.55-200";
    $cli->SetTempBlacklistedIPs($data);
  } else {
    die "Error: ".$cli->getErrMessage.", quitting";
  }

CommuniGate Pro Guide. Copyright © 2020, AO StalkerSoft