Using API to send emails with HmailServer

Visits: 2094



The hMailServer COM API lets you write your own scripts and applications that integrate with hMailServer. Almost all objects in hMailServer are accessible using the COM library. As an example, both hMailServer Administrator and the PHP WebAdmin is entirely based upon the COM library. Besides writing application like theese two, you can write scripts that are automatically run when certain events take place. For example, you can write a script that filters messages before they are delivered to the recipients. 

The Best way to have a completely secure server is to install our simple to install EC2 including Roundcube WebMail. You can get started with an Email Cloud Server that is wonderful combination of MS Windows Server  and Open Source Software. It is available through AWS Marketplace as Hmailserver on Windows Server with Roundcube Webmail so that you can check email anywhere and from any device.

Also Check it out AWS Marketplace: Mail Server on Linux Postfix using MySQL for tons of users (

The Application object is the root object in hMailServers COM model. Using this object, you can access all hMailServer objects and settings. Before accessing any of the properties and methods on the Application object, you must call Application.Authenticate with valid credentials.

The hMailServer API behaves as most other COM APIs, but there are some special behavior which relates to exception handling and permissions.

It is possible to create triggers in hMailServer. Triggers are script which are executed when certain actions occur. Triggers are created by adding the script to the EventHandlers-file in the hMailServer Events folder.

Basic steps

These are the basic steps to perform when you want to access the hMailServer COM API.

  1. Create an instance of the hMailServer Application object. How to do this depends on what programming language you use. In VBScript, you call CreateObject(“hMailServer.Application”).
  2. Authenticate. Before you can call any other methods in the API, you need to authenticate. This is done using the Authenticate() method on the Application object. This is required to prevent unauthorized users to access your hMailServer installation.
  3. Call the methods and use the properties you need.

Change log

For a list of changes in the COM API, see the COM API Changelog

.NET Class

The complete COM API is available as a .NET class in the hMailserver bin directory …\hmailserver\bin\Interop.hMailServer.dll



Please see the COM API examples page