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.
<?php
$api=new COM('IceWarpServer.APIObject');
$tarpit = $api->GetProperty('C_Mail_Security_Tarpit_Enable');
echo 'Tarpitting is '.($tarpit==0 ? 'disabled':'enabled').'<br />';
$api->SetProperty('C_Mail_Security_Tarpit_Enable', ($tarpit==0 ? 1 : 0));
echo 'Tarpitting has been '.($tarpit==0 ? 'enabled':'disabled');
$api->Save();
$api->UpdateConfiguration();
?>
IceWarpServer.DomainObject
Functions to set and query domain settings, creating/editing/deleting domain.
<?php
$dom=new COM('IceWarpServer.DomainObject');
$dom->New('icewarpdemo.com');
$dom->Save();
echo 'icewarpdemo.com was created';
?>
IceWarpServer.AccountObject
Functions to set and query accounts settings.
<?php
$account=new COM('IceWarpServer.AccountObject');
$account->New('newuser@icewarpdemo.com');
$account->SetProperty('U_Password', 'newpassword');
if ($account->Save())
echo 'Account newuser@icewarpdemo.com was created';
else
echo 'Error creating account newaccount@icewarpdemo.com';
?>
IceWarpServer.RemoteAccountObject, IceWarpServer.ScheduleObject
Simple set of functions to set and query remote account settings.
<?php
$ra=new COM('IceWarpServer.RemoteAccountObject');
$ra->Open(0); // Open the first remote account
$schedule = $ra->GetSchedule('ra_schedule');
if($schedule->Count>0)
{
$schedule->Select(0); // Select the first schedule as active
$schedule->SetProperty("s_weekdays_su", false);
$schedule->SetProperty("s_weekdays_mo", true);
$schedule->SetProperty("s_weekdays_tu", false);
$schedule->SetProperty("s_weekdays_we", true);
$schedule->SetProperty("s_weekdays_th", false);
$schedule->SetProperty("s_weekdays_fr", true);
$schedule->SetProperty("s_weekdays_sa", false);
$schedule->SetProperty("s_scheduletype", 0); // Every x minutes type
$schedule->SetProperty("s_every", 1200); // Set 20 minutes
$schedule->SetProperty("s_wholeday", true); // Whole day interval
}
$ra->SetSchedule('ra_schedule', $schedule); // Set the changed schedule
$ra->Save();
?>
IceWarpServer.StatisticsObject
Interface for querying statistical information like running time and traffic for services.
<?php
$stats=new COM('IceWarpServer.StatisticsObject');
$stats->Poll('SMTP');
echo $stats->GetProperty('ST_SMTP_MessageOut') . ' messages sent out';
?>
IceWarpCOM.GroupWare
Interface for groupware access using the GroupWare API and GroupWare PHP class.
<?php
require_once('.\webmail\server\inc\gw\gwapi.php');
$gw=new MerakGWAPI();
$gw->user='john.doe@icewarpdemo.com';
$gw->pass='secret';
$gw->Login();
$gid = $gw->OpenGroup('*');
$fid = $gw->OpenFolder($gid, 'Contacts');
$list = $gw->ParseParamLine($gw->FunctionCall('GetContactList', $fid));
$data = array();
for ($i=0;$i
$id = $list[$i][CONTACT_ID];
$data[] = $gw->FunctionCall('GetVCard', $fid, $id);
}
$vcard=' BEGIN:VCARD VERSION:2.1 PRODID:-//IceWarp//Merak Mail Server 9.2.1//EN FN:John Doe N:Doe;John NOTE;ENCODING=QUOTED-PRINTABLE:Multi-line note=0D=0AAnother=0D=0AMore=0D=0AAnd more URL;http://www.icewarp.com/ UID:370398ef4001 CLASS:PUBLIC SEQUENCE:1 CREATED:20080503T170731Z DTSTAMP:20080503T170731Z LAST-MODIFIED:20080503T170747Z ORG:IceWarp Inc. END:VCARD';
$gw->FunctionCall('AddVCard', $fid, $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
<?php
$com = new COM("IceWarpCOM.Mailer");
$com->RemoteHost = "localhost";
$com->Helo = "mycomputer.icewarpdemo.com";
$com->FromName = "John Doe";
$com->FromAddress = "john@icewarpdemo.com";
$com->AddRecipient("mother@icewarpdemo.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;
else echo "Mail was sent";
$com = null;
?>
Plaintext message in ASP
<%
Set Com = Server.CreateObject( "IceWarpCOM.Mailer" )
Com.RemoteHost = "localhost"
Com.Helo = "localhost"
Com.FromName = "User One"
Com.FromAddress = "user1@demodomain.com"
Com.MailFrom = Mail.FromAddress
Com.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
<?php
$com = new COM("IceWarpCOM.Mailer");
$com->RemoteHost = "localhost";
$com->Helo = "mycomputer.icewarpdemo.com";
$com->FromName = "John Doe";
$com->FromAddress = "john@icewarpdemo.com";
$com->AddRecipient("mother@icewarpdemo.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;
else echo "Mail was sent";
$com = null;
?>
Message with attachement in PHP
<?php
$com = new COM("IceWarpCOM.Mailer");
$com->RemoteHost = "localhost";
$com->Helo = "mycomputer.icewarpdemo.com";
$com->FromName = "John Doe";
$com->FromAddress = "john@icewarpdemo.com";
$com->AddRecipient("bob@icewarpdemo.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;
else echo "Mail was sent";
$com = null;
?>
Message with embedded image in PHP
<?php
$com = new COM("IceWarpCOM.Mailer");
$com->RemoteHost = "localhost";
$com->Helo = "mycomputer.icewarpdemo.com";
$com->FromName = "John Doe";
$com->FromAddress = "john@icewarpdemo.com";
$com->AddRecipient("bob@icewarpdemo.com", "Bob Smith");
$com->Subject = "Bob you have to see this...";
$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;
else echo "Mail was sent";
$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@icewarpdemo.com must be on John's roaster)
<?php
$com = new COM("IceWarpCOM.IMMessage");
$com->MessageFrom = "admin@icewarpdemo.com";
$com->MessageTo = "john@icewarpdemo.com";
$com->MessageSubject = "Hey pal";
$com->MessageBody = "This IM message was sent from my web site";
$com->SendMessage();
$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 sending 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
<?php
$com = new COM("IceWarpCOM.IMMessage");
$buddy = "john@icewarpdemo.com";
echo $buddy . ' is ';
if (!$com->IsOnline($buddy)) echo 'NOT';
echo 'online';
$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)
<?php
$com = new COM('IceWarpCOM.IDP');
$com->AddFiles('c:\temp\temp.zip', 'c:\windows\temp');
$com = null;
?>