Developers API

Open API provides full control of the server- account and domain management, server settings, scheduling, statistics and much more, accessible from within an arbitrary script or program. API is available for all languages with COM objects support, immediately after installation, free of any charge.


Integration with mail server made easy.

API Documentation

API brings you the best way to maintain your IceWarp server from any programming language such as Visual C++, Visual Studio, Delphi, FreePascal, PHP, ASP, Visual Basic, Microsoft .NET or any other. You can use the RPC (Remote Procedure Call) to access the server remotely or COM object.


More information can be found in API folder of installation root. In api\classes.txt file there is a complete list of functions for COM objects. The complete list of variables accessible via API is in api\Delphi\APIConst.pas file. There are also folders for other programming languages but the most important and updated is always Delphi folder. In that folder you'll also find source code for Command Line Tool - tool.exe, which is using API heavily and can serve as a good example even for the most demanding applications.


There are six COM objects:

  • MerakCOM.APIObject
  • MerakCOM.DomainObject
  • MerakCOM.AccountObject
  • MerakCOM.RemoteAccountObject
  • MerakCOM.ScheduleObject
  • MerakCOM.StatisticsObject

All COM objects below can operate with variable names published in API folder.

MerakCOM.APIObject

Provides functions to set and query global Merak settings, also gives the power to create/edit/delete domains in Merak. Also can be used to add/edit/delete accounts.


<?    
$api=new COM('MerakCOM.APIObject');        
$tarpit = $api->GetProperty('C_Config_Delivery_Tarpitting');      
echo 'Tarpitting is '.($tarpit==0 ? 'disabled':'enabled').'<br />';        
$api->SetProperty('C_Config_Delivery_Tarpitting', ($tarpit==0 ? 1 : 0));      
echo 'Tarpitting has been '.($tarpit==0 ? 'enabled':'disabled');       
$api->Save();    
$api->UpdateConfiguration();      
$api->Release();  
?> 

MerakCOM.DomainObject

Provides functions to set and query domain settings, creating/editing/deleting domain.


<?    
$dom=new COM('MerakCOM.DomainObject');
$dom->New('newdomain.com');    
$dom->Save();      
echo 'newdomain.com was created';       
$dom->Release();  
?>  

MerakCOM.AccountObject

Provides functions to set and query accounts settings.


<?    
$account=new COM('MerakCOM.AccountObject');      
$account->New('newuser@newdomain.com');    
$account->SetProperty('U_Password', 'newpassword');      
if ($account->Save())      
echo 'Account newaccount@newdomain.com was created';    
else      
echo 'Error creating account newaccount@newdomain.com';       
$account->Release();  
?> 

MerakCOM.RemoteAccountObject

Provides simple set of functions to setting and querying remote account settings.


<?    
$ra->Open(0); // Opens the first remote account    
$schedule = $ra->GetSchedule('ra_schedule'); // Retrieve the schedule for the object      
$schedule->Count = 1; // Sets 1 schedule item      
$schedule->SetProperty("s_weekdays_su", true);    
$schedule->SetProperty("s_weekdays_mo", true);    
$schedule->SetProperty("s_weekdays_tu", true);    
$schedule->SetProperty("s_weekdays_we", true);    
$schedule->SetProperty("s_weekdays_th", true);    
$schedule->SetProperty("s_weekdays_fr", true);    
$schedule->SetProperty("s_weekdays_sa", true);    
$schedule->SetProperty("s_scheduletype", 0); // Every x minutes type    
$schedule->SetProperty("s_every", 1200); // Sets 20 minutes    
$schedule->SetProperty("s_wholeday", true); // whole day interval      
$ra->SetSchedule('ra_schedule', $schedule); // Sets the changed schedule     
$ra->Save(); // Save the changed remote account  
?>   

MerakCOM.ScheduleObject

Provides functions to setup and query schedule for any schedule structure.


<?    
$stats=new COM('MerakCOM.StatisticsObject');      
$stats->Poll('SMTP');      
echo  $stats->GetProperty('st_smtp_messagesout')  . ' messages sent out';      
$statsi->Release();  
?>