Developers API
Open API provides full control of the server, groupware access, 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. Plus there are utilities which will help you simulate server traffic, test DNS configuration, analyze and inspect errors, for the most reliable and trouble-free integration.
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.
COM objects can also be used for sending email and IM messages without knowing all the communication protocols. It also provides access to IDP routines for IDP archive manipulation.
Available COM objects:
- IceWarpServer.APIObject
- IceWarpServer.DomainObject
- IceWarpServer.AccountObject
- IceWarpServer.RemoteAccountObject
- IceWarpServer.ScheduleObject
- IceWarpServer.StatisticsObject
- IceWarpCOM.GroupWare
- IceWarpCOM.Mailer
- IceWarpCOM.IMMessage
- IceWarpCOM.IDP
All COM objects can operate with variable names published in API folder.
IceWarpServer.APIObject
Functions to set and query global server settings, also gives the power to create/edit/delete domains in mail server. Also can be used to add/edit/delete accounts.
<?
$api=new COM('IceWarpServer.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();
?>
IceWarpServer.DomainObject
Functions to set and query domain settings, creating/editing/deleting domain.
<?
$dom=new COM('IceWarpServer.DomainObject');
$dom->New('newdomain.com');
$dom->Save();
echo 'newdomain.com was created';
$dom->Release();
?>
IceWarpServer.AccountObject
Functions to set and query accounts settings.
<?
$account=new COM('IceWarpServer.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();
?>
IceWarpServer.RemoteAccountObject, IceWarpServer.ScheduleObject
Simple set of functions to set and query remote account settings.
<?
$ra=new COM('IceWarpServer.RemoteAccountObject');
$ra->Open(0); // Opens the first remote account
$schedule = $ra->GetSchedule('ra_schedule');
// Retrieve 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
?>
IceWarpServer.StatisticsObject
Interface for querying statistical information like running time and traffic for services.
<?
$stats=new COM('IceWarpServer.StatisticsObject');
$stats->Poll('SMTP');
echo $stats->GetProperty('st_smtp_messagesout') . ' messages sent out';
$statsi->Release();
?>
IceWarpCOM.GroupWare
Interface for groupware access using the GroupWare API and GroupWare PHP class.
<?
require_once('gw.php');
$gw=new MerakGWAPI();
$gw->user='john@doe.com;
$gw->pass='secret';
$gw->Login();
$gw->OpenGroup('*');
$gw->OpenFolder('Contacts');
$vcard=' BEGIN:VCARD VERSION:2.1 PRODID:-//IceWarp//Merak Mail Server 9.0.0-3//EN FN:John Doe N:Doe;John NOTE;ENCODING=QUOTED-PRINTABLE:Multiple line note=0D=0AAnother=0D=0AMore=0D=0AAnd more URL;http://www.icewarp.com/ UID:370398ef4001 CLASS:PUBLIC SEQUENCE:1 CREATED:20070803T170731Z DTSTAMP:20070803T170731Z LAST-MODIFIED:20070803T170747Z ORG:IceWarp Ltd. END:VCARD';
$gw->FunctionCall($fid, 'AddVCard', $vcard);
?>
IceWarpCOM.Mailer
Functions to send plain text or HTML messages, add attachments, embed images, specify charsets, Cc, Reply-To or any custom headers. 100% syntax compatible with the famous ASP Email component.
Plaintext message in PHP
<?
$com = new COM("IceWarpCOM.Mailer");
$com->RemoteHost = "smtp.mydomain.com";
$com->Helo = "mycomputer.mydomain.com";
$com->FromName = "John Doe";
$com->FromAddress = "john@mydomain.com";
$com->AddRecipient("mother@mydomain.com", "Mom");
$com->Subject = "Hi mom";
$com->BodyText = "Just wanted to let you know I have new
IceWarp Server installed.". "\n\nSincerely,". "\nJohn";
if (!$com->SendMail()) echo $com->Response;
$com->Release();
$com = null;
?>
Plaintext message in ASP
<%
Set Mail = Server.CreateObject( "IceWarpCOM.Mailer" )
Mail.RemoteHost = "localhost"
Mail.Helo = "localhost"
Mail.FromName = "User One"
Mail.FromAddress = "user1@demodomain.com"
Mail.MailFrom = Mail.FromAddress
Mail.AddRecipient "user2@demodomain.com.br", "User Two"
Com.Subject = "Test message"
Com.IsHTML = "True"
Com.BodyText = "IceWarp COM objects under IIS work"
If Not Com.SendMail Then Response.Write com.Response
Set Com = Nothing
%>
HTML message in PHP
<?
$com = new COM("IceWarpCOM.Mailer");
$com->RemoteHost = "smtp.mydomain.com";
$com->Helo = "mycomputer.mydomain.com";
$com->FromName = "John Doe";
$com->FromAddress = "john@mydomain.com";
$com->AddRecipient("mother@mydomain.com", "Mom");
$com->Subject = "Hi mom";
$com->IsHTML = True;
$com->BodyText = "... one more thing - I can now send even
HTML messages from my scripts!". "\n\nSincerely,". "\nJohn";
if (!$com->SendMail()) echo $com->Response;
$com->Release();
$com = null;
?>
Message with attachement in PHP
<?
$com = new COM("IceWarpCOM.Mailer");
$com->RemoteHost = "smtp.mydomain.com";
$com->Helo = "mycomputer.mydomain.com";
$com->FromName = "John Doe";
$com->FromAddress = "john@mydomain.com";
$com->AddRecipient("bob@mydomain.com", "Bob Smith");
$com->Subject = "Annual report";
$com->BodyText = "Hi Bob,\n". "sending you the annual report.
See attachment.". "\n\nRegards,". "\nJohn";
$com->AddAttachment( "c:\\Documents and Settings\\John\\report.rtf");
if (!$com->SendMail()) echo $com->Response;
$com->Release();
$com = null;
?>
Message with embedded image in PHP
<?
$com = new COM("IceWarpCOM.Mailer");
$com->RemoteHost = "localhost";
$com->Helo = "localhost";
$com->FromName = "Martin";
$com->FromAddress = "admin@localhost";
$com->AddRecipient("admin@localhost", "Lobogo :)");
$com->Subject = "COM obj test";
$com->IsHTML = "True";
$com->BodyText = "<html><head>". "<meta
http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1
\">". "</head><body><img src=\"cid:123\">". "</body></html>";
$com->AddEmbeddedImage("c:\\image.jpg", "123");
if (!$com->SendMail()) echo $com->Response;
$com->Release();
$com = null;
?>
IceWarpCOM.IMMessage
Functions to check status of IM contacts and send IM messages, with support for any custom XML tags.
IM message in PHP
(bob@mydomain.com must be on John's roaster)
<?
$com = new COM("IceWarpCOM.IMMessage");
$com->MessageFrom = "john@mydomain.com";
$com->MessageTo = "bob@mydomain.com";
$com->MessageSubject = "Hey pal";
$com->MessageBody = "This IM message was sent from my web site";
if (!$com->SendMessage()) echo "Error";
$com->Release();
$com = null;
?>
IM Message in ASP (sender and recipient must have each other on their roasters)
<%
Set IM = Server.CreateObject("IceWarpCOM.IMMessage")
Im.MessageFrom = "user1@demodomain.com"
Im.MessageTo = "user2@demodomain.com"
Im.MessageSubject = "TEST"
Im.MessageBody = "UNO DUE TRES QUATRO"
If Not Im.SendMessage Then
Response.Write "Error sendin message to " & Im.MessageTo & " "
Else Response.Write "Message Sent "
End If
If Im.IsOnline( Im.MessageTo ) Then
Response.Write Im.MessageTo & " is online "
End If
Set Im = Nothing
%>
IM Presence Query in PHP
<?
$com = new COM("IceWarpCOM.IMMessage");
$buddy = "bob@mydomain.com";
echo $buddy . ' is ';
if (!$com->IsOnline($buddy)) echo 'NOT';
echo 'online';
$com->Release();
$com = null;
?>
IceWarpCOM.IDP
Functions to add and extract files to/from IDP archives.
Add file to IDP archive in PHP
(must be run by user with directory write access)
<?
$com = new COM('IceWarpCOM.IDP');
$com->AddFiles('temp.idp', 'c:\windows\temp')
$com->Release();
$com = null;
?>