hMailServer on Windows Server 2025 on Azure User Guide
Overview
This guide covers the deployment and use of hMailServer on Windows Server 2025 on Microsoft Azure, using cloudimg's virtual machine image from the Azure Marketplace.
hMailServer is a free, open source mail server for Windows (AGPL-3.0). It receives and sends mail over SMTP and serves mailboxes over IMAP and POP3, with domains, accounts, aliases, distribution lists, rules, anti-spam and anti-virus hooks, all managed in the hMailServer Administrator console. This image runs it as a Windows service on a local MariaDB database, with TLS on every mail port from the first boot of your VM.
The image is Microsoft Windows Server 2025 Datacenter with the Desktop Experience (the full graphical interface), Gen2, x64, built from Microsoft's own image on the Azure Marketplace (MicrosoftWindowsServer:WindowsServer:2025-datacenter-g2, version 26100.33828.261112). The Windows Server licence is included in the VM price and billed by Microsoft.
What's included:
- hMailServer 5.7.2 (build 3164), 64-bit, from the hMailServer project's official release, its checksum verified when the image was built, in
C:\Program Files\hMailServer\, with hMailServer Administrator and a shortcut to it on the desktop - MariaDB Server 11.4.14 LTS for Windows, from the MariaDB Foundation's release (checksum and signature verified), in
C:\Program Files\MariaDB 11.4\, as hMailServer's database. It listens on127.0.0.1:3306only, so nothing outside the VM can reach it. hMailServer's other database option, Microsoft SQL Server Compact, has been out of support since 2021 and is not installed - Both running as Windows services under their own virtual accounts (NT SERVICE\hMailServer and NT SERVICE\MariaDB), never as SYSTEM or an administrator
- This VM's own secrets, made at the first boot of your VM: a random hMailServer administrator password, random passwords for MariaDB's
rootandhmailserverusers, and a new TLS certificate and private key (RSA 3072, self-signed, named after the VM). The passwords are saved inC:\ProgramData\hmailserver-credentials.txt, which only administrators can read. No password, key or certificate ships in the image, so no two VMs share one - The mail ports, with TLS on all of them: SMTP 25 (STARTTLS offered), submission 587 (STARTTLS required), SMTPS 465, IMAP 143 (STARTTLS required), IMAPS 993, POP3 110 (STARTTLS required) and POP3S 995. TLS 1.2 and 1.3 only
- Safe defaults: sign-in is accepted only over TLS, the server relays mail to other domains only for signed-in users (it is not an open relay), and auto-ban blocks an address after repeated failed sign-ins
- Windows Firewall rules (group hMailServer) allowing those seven ports in, for
hMailServer.exeonly - No mail domain or account: you add your own (Step 6)
- Windows Server 2025 Datacenter, Desktop Experience, version 24H2, build 26100.33828, with Microsoft's November 2026 cumulative update. Windows Update ran during the build and reported nothing pending when the image was captured on 1 December 2026
- The Azure VM agent, so Azure features such as Reset password and Run command work
- cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours
Platform: Microsoft Azure (Gen2 Hyper-V; Trusted Launch, NVMe and accelerated networking sizes supported)
Administrator account: the user name and password you choose when you deploy the VM. There is no default Windows password on this image.
hMailServer data: C:\ProgramData\hMailServer (settings file, message store, logs). Database: C:\ProgramData\MariaDB\data.
Prerequisites
- An Azure subscription
- A Remote Desktop client: Remote Desktop Connection (
mstsc) on Windows, Windows App (formerly Microsoft Remote Desktop) on macOS, or Remmina on Linux - The public IP address of the machine you will connect from, so you can allow Remote Desktop from that address only
- A domain name whose DNS you control, for the mail you will receive (Step 7)
- To send mail to other domains: an SMTP relay ("smart host") account that accepts mail on port 587, from your email provider or a sending service (Step 8). Azure blocks outbound port 25 from most subscriptions
Recommended size: Standard_B2ms (2 vCPUs, 8 GiB memory). Use a larger size and a data disk for many mailboxes or large ones.
Step 1: Deploy the Virtual Machine
Option A: Azure Portal
- In the Azure Marketplace, search for "hMailServer on Windows Server 2025 cloudimg"
- Select the offer and click Create
- Configure the basics:
- Subscription and Resource group: select or create
- Virtual machine name and Region: your choice. The VM name becomes the Windows computer name, which this image uses as the server's host name and in its TLS certificate
- Size:
Standard_B2msrecommended - Under Administrator account, enter a Username and a Password that you choose. Azure refuses reserved names such as "administrator", "admin" and "guest"
- Under Inbound port rules, allow RDP (3389). Azure then opens port 3389 to the whole internet, so restrict it straight after deployment (step 7)
- Click Review + create, then Create
- When the deployment finishes, open the VM's Networking (Network settings) page:
- edit the inbound rule for port 3389 and set Source to My IP address (or your office or VPN address range)
- add an inbound rule for TCP 25, from Any, so other mail servers can deliver to you
- add an inbound rule for TCP 587, 993 (and 465, 995, 143, 110 if your clients use them), from the addresses your users connect from, or from Any for users on the move: every one of these ports needs a password and TLS
Option B: Azure CLI
Accept the offer terms once per subscription, then create the VM with no inbound rules. Leave out --admin-password and the CLI asks for the password, which keeps it out of your shell history:
az vm image terms accept --urn cloudimg1647283583153:hmailserver-windows-server:default:latest
az vm create \
--resource-group myResourceGroup \
--name mail1 \
--image cloudimg1647283583153:hmailserver-windows-server:default:latest \
--size Standard_B2ms \
--admin-username <your-admin-name> \
--public-ip-sku Standard \
--nsg-rule NONE
Then allow Remote Desktop from your own address only, allow mail in, and read the VM's public IP:
az network nsg rule create \
--resource-group myResourceGroup \
--nsg-name mail1NSG \
--name allow-rdp-from-my-ip \
--priority 1000 \
--direction Inbound --access Allow --protocol Tcp \
--destination-port-ranges 3389 \
--source-address-prefixes <your-public-ip>/32
az network nsg rule create \
--resource-group myResourceGroup \
--nsg-name mail1NSG \
--name allow-smtp \
--priority 1010 \
--direction Inbound --access Allow --protocol Tcp \
--destination-port-ranges 25 \
--source-address-prefixes '*'
az network nsg rule create \
--resource-group myResourceGroup \
--nsg-name mail1NSG \
--name allow-mail-clients \
--priority 1020 \
--direction Inbound --access Allow --protocol Tcp \
--destination-port-ranges 587 993 \
--source-address-prefixes <client-addresses-or-*>
az vm show --resource-group myResourceGroup --name mail1 --show-details --query publicIps -o tsv
Step 2: Connect with Remote Desktop
- Open your Remote Desktop client and connect to the VM's public IP address
- Windows: run
mstsc, enter the IP address and click Connect - macOS: in Windows App, add a PC with the IP address
- Linux: in Remmina, create an RDP connection to the IP address
- When asked for credentials, sign in as
<vm-name>\<your-admin-name>with the password you set at deployment. On Windows, choose More choices, then Use a different account - Accept the certificate warning: the VM uses a self-signed Remote Desktop certificate
Windows may show its privacy settings screen at your first sign-in; choose your settings and click Accept.
hMailServer does not need you to stay signed in: it is a Windows service and runs from the moment the VM starts. Sign out (or just disconnect) when you are done.
Step 3: Check that hMailServer is running
At the first start of your VM, a one-time task waits for Azure to finish setting the VM up, then makes this VM's MariaDB database and passwords, its hMailServer administrator password and its TLS certificate, configures the mail ports, starts both services, and removes itself. It takes about a minute after the VM is first reachable. Open Windows PowerShell with Run as administrator and run:
Test-Path C:\ProgramData\hmailserver-firstboot.done
Get-Service hMailServer, MariaDB | Select-Object Name, Status, StartType
Get-NetTCPConnection -State Listen | Where-Object LocalPort -in 25,110,143,465,587,993,995,3306 |
Sort-Object LocalPort | Select-Object LocalAddress, LocalPort, @{n='Process';e={(Get-Process -Id $_.OwningProcess).ProcessName}}
True
Name Status StartType
---- ------ ---------
hMailServer Running Automatic
MariaDB Running Automatic
LocalAddress LocalPort Process
------------ --------- -------
0.0.0.0 25 hMailServer
0.0.0.0 110 hMailServer
0.0.0.0 143 hMailServer
0.0.0.0 465 hMailServer
0.0.0.0 587 hMailServer
0.0.0.0 993 hMailServer
0.0.0.0 995 hMailServer
127.0.0.1 3306 mysqld
Every mail port listens on all addresses (0.0.0.0) for hMailServer; MariaDB (mysqld) listens on 127.0.0.1 only, so it cannot be reached from outside the VM.
Step 4: Read this VM's passwords
The first-boot task saved this VM's passwords in a file only administrators can read. In the same elevated PowerShell window:
Get-Content C:\ProgramData\hmailserver-credentials.txt
# hMailServer on Windows Server 2025 by cloudimg: this VM's own passwords (made at first boot).
# Open "hMailServer Administrator" on the desktop (Remote Desktop), connect to localhost, sign in as Administrator.
# To change the administrator password: hMailServer Administrator > Settings > Advanced > Administration password, then Save.
# Guide: https://www.cloudimg.co.uk/guides/hmailserver-on-windows-server-2025-azure/
hmailserver.admin.user=Administrator
hmailserver.admin.password=<24 random characters>
hmailserver.hostname=mail1
hmailserver.tls.certificate=C:\ProgramData\hMailServer\Certificates\mail1.crt
hmailserver.tls.privatekey=C:\ProgramData\hMailServer\Certificates\mail1.key
hmailserver.tls.certificate.sha256=650545D9EDD3F7E9DA693FD2E46C083C31C306D9058A55870330D91A824D46B5
mariadb.host=127.0.0.1
mariadb.port=3306
mariadb.root.user=root
mariadb.root.password=<32 random characters>
mariadb.hmailserver.database=hmailserver
mariadb.hmailserver.user=hmailserver
mariadb.hmailserver.password=<32 random characters>
This is the file of a VM named mail1, with the passwords shown as placeholders: your file holds your VM's own name, certificate and passwords, made at its first boot.
hmailserver.admin.passwordsigns you in to hMailServer Administrator (and to hMailServer's COM API) asAdministratorhmailserver.tls.certificate.sha256is the fingerprint of this VM's certificate: a mail client that warns about the self-signed certificate shows it, so you can check it before you accept- the MariaDB passwords are for maintenance and backups only: hMailServer already uses its own
Keep a copy of these passwords somewhere safe, such as your password manager. Changing a password later does not update this file.
Step 5: Open hMailServer Administrator
- Double-click hMailServer Administrator on the desktop
- In the Connect window, select localhost and click Connect
- Enter the
hmailserver.admin.passwordvalue from Step 4 and click OK
Select Status in the tree. Its Server tab shows hMailServer's version, that it is running, and its database (MySQL type, on 127.0.0.1, database hmailserver); its Status tab shows when the server started, the processed messages and the open SMTP, POP3 and IMAP sessions.

The mail ports this image set up are under Settings > Advanced > TCP/IP ports, each with its TLS mode and this VM's certificate:

Step 6: Add your domain and accounts
- In the tree, select Domains, then click Add...
- Enter your domain name (for example
example.com), keep Enabled ticked, and click Save - Under the new domain, select Accounts, then click Add...
- Enter the mailbox name (for example
alice), a password, and click Save

Add aliases (other addresses that deliver to an account) under Aliases, and distribution lists under Distribution lists.
Step 7: Point your domain at the server (DNS)
For other mail servers to deliver to you, publish these records at your DNS provider (replace the names and address with yours):
| Record | Name | Value |
|---|---|---|
| A | mail.example.com |
the VM's public IP address |
| MX | example.com |
mail.example.com, priority 10 |
| TXT (SPF) | example.com |
v=spf1 mx include:<your-smart-host's-spf> -all |
For the best delivery of mail you send, also:
- set Settings > Protocols > SMTP > Delivery of e-mail > Local host name to
mail.example.com, the name in your A and MX records - give the public IP a reverse DNS name (PTR) that matches, from the Azure CLI (the IP needs a DNS label first):
az network public-ip update --resource-group myResourceGroup --name mail1PublicIP \
--dns-name mail1-example --reverse-fqdn mail.example.com.
- add DKIM signing in hMailServer (the domain's DKIM Signing tab) and publish its public key as the TXT record your smart host or hMailServer's documentation describes
Step 8: Send mail out through a smart host
Azure blocks outbound connections to TCP port 25 from VMs in most subscription types, so hMailServer cannot deliver straight to other mail servers (see Microsoft's article "Troubleshoot outbound SMTP connectivity problems in Azure"). Send through an SMTP relay on port 587 instead:
- In hMailServer Administrator, open Settings > Protocols > SMTP, tab Delivery of e-mail
- Under SMTP Relayer, enter your relay's Remote host name (for example
smtp.your-provider.com) and Remote TCP/IP port587 - Tick Server requires authentication and enter the relay account's User name and Password
- Set Connection security to STARTTLS (Required)
- Click Save
Mail for your own domains is still delivered locally; everything else goes through the relay. Receiving mail on port 25 is not affected by Azure's block.
Step 9: Connect a mail client
Use these settings in Outlook, Thunderbird, Apple Mail or a phone:
| Server | Port | Security | User name | |
|---|---|---|---|---|
| Incoming (IMAP) | mail.example.com |
993 | SSL/TLS | the full address, e.g. alice@example.com |
| Outgoing (SMTP) | mail.example.com |
587 | STARTTLS | the full address, with the same password |
POP3 is on 995 (SSL/TLS) if you prefer it. Until you install a certificate from a public authority (Step 10), clients warn that the certificate is not trusted: check that the fingerprint matches hmailserver.tls.certificate.sha256 (Step 4) before you accept it.
Step 10: Use your own certificate
The certificate made at first boot is self-signed. To use one from a public certificate authority for mail.example.com (for example from Let's Encrypt with an ACME client such as win-acme, or one you bought):
- Save the certificate (with its chain) and its private key as PEM files, for example in
C:\ProgramData\hMailServer\Certificates, which only administrators and hMailServer can read - In hMailServer Administrator, open Settings > Advanced > SSL certificates, click Add..., give it a name and select the two files, then Save
- Open Settings > Advanced > TCP/IP ports, and for each port select the new certificate under SSL Certificate, then Save
- Restart hMailServer: run
Restart-Service hMailServerin an elevated PowerShell window
Step 11: Keeping Windows and hMailServer up to date
Windows: Windows Update is on, as in Microsoft's image. Check for updates in Settings > Windows Update, and plan restarts: hMailServer and MariaDB start again by themselves after a restart.
hMailServer: download a newer release from the hMailServer releases page, back up first (Security recommendations), then run its setup as an administrator: it keeps your settings file and upgrades the database itself.
MariaDB: 11.4 is a long-term support release. To apply a newer 11.4 patch release, stop both services, replace the files in C:\Program Files\MariaDB 11.4 with those from the new mariadb-11.4.<n>-winx64.zip, and start MariaDB, then hMailServer.
Server Components
| Component | Version or setting | Where |
|---|---|---|
| hMailServer | 5.7.2 build 3164, x64 | C:\Program Files\hMailServer\Bin\hMailServer.exe (service hMailServer, NT SERVICE\hMailServer, Automatic) |
| hMailServer Administrator | 5.7.2 | C:\Program Files\hMailServer\Bin\hMailAdmin.exe |
| MariaDB Server | 11.4.14 LTS | C:\Program Files\MariaDB 11.4\ (service MariaDB, NT SERVICE\MariaDB, Automatic), 127.0.0.1:3306 only |
| Database | hmailserver, user hmailserver (rights on that database only) |
C:\ProgramData\MariaDB\data |
| TLS | TLS 1.2 and 1.3; this VM's own RSA 3072 certificate | C:\ProgramData\hMailServer\Certificates |
| Mail ports | 25, 587, 465, 143, 993, 110, 995 | Windows Firewall group "hMailServer" |
| Windows Server | 2025 Datacenter, Desktop Experience, 24H2, build 26100.33828 |
Filesystem Layout
| Path | What it holds |
|---|---|
C:\Program Files\hMailServer\ |
hMailServer's programs (Bin), database scripts (DBScripts), SOURCE-OFFER.txt (where the source code of hMailServer and MariaDB is) |
C:\Program Files\MariaDB 11.4\ |
MariaDB's programs (bin) and its licence (COPYING) |
C:\ProgramData\hMailServer\ |
hMailServer.ini (database connection), Data (the message store), Logs, Events, Temp, Certificates. SYSTEM, Administrators and the hMailServer service only |
C:\ProgramData\MariaDB\data\ |
The MariaDB data directory and its my.ini. SYSTEM, Administrators and the MariaDB service only |
C:\ProgramData\hmailserver-credentials.txt |
This VM's passwords and certificate fingerprint. SYSTEM and Administrators only |
The OS disk is Microsoft's 127 GB Windows disk (C:, NTFS). On sizes that have an Azure temporary disk (D:), never keep mail there: Azure can wipe it when the VM is stopped or moved. For large mailboxes, add a managed data disk and move the message store to it: stop hMailServer, copy C:\ProgramData\hMailServer\Data to the new disk with its permissions (robocopy C:\ProgramData\hMailServer\Data F:\hMailServer\Data /E /COPYALL), set DataFolder= under [Directories] in C:\ProgramData\hMailServer\hMailServer.ini to the new folder, and start hMailServer again.
Managing the Services
From an elevated PowerShell window:
# restart hMailServer (for example after changing a certificate)
Restart-Service hMailServer
# stop both, MariaDB last
Stop-Service hMailServer
Stop-Service MariaDB
# start both, MariaDB first
Start-Service MariaDB
Start-Service hMailServer
Scripts and Log Files
| File | What it is |
|---|---|
C:\ProgramData\hMailServer\Logs\hmailserver_<date>.log |
hMailServer's log, once you turn logging on in Settings > Logging |
C:\ProgramData\hMailServer\Logs\ERROR_hmailserver_<date>.log |
hMailServer's error log (always on) |
C:\ProgramData\MariaDB\data\<computer name>.err |
MariaDB's error log |
C:\ProgramData\hmailserver-firstboot.log |
What the one-time first-boot task did |
C:\ProgramData\hmailserver-firstboot.done |
Written when the first-boot task finished |
On Startup
At the first start of your VM, the scheduled task \cloudimg-firstboot (SYSTEM) runs once:
- It waits until Azure has finished setting up the VM
- It makes a new MariaDB data directory, listening on
127.0.0.1only, with this VM's ownrootpassword and ahmailserveruser with its own password and rights on thehmailserverdatabase only; it removes MariaDB's otherrootaccounts and its opentestdatabase - It sets this VM's hMailServer administrator password, and hMailServer creates its database
- It makes this VM's TLS certificate and private key, sets up the seven mail ports with TLS, turns TLS 1.0 and 1.1 off, requires TLS for sign-in and sign-in for relaying, and turns auto-ban on
- It writes
C:\ProgramData\hmailserver-credentials.txt, readable by administrators only - It sets both services to start with Windows, writes
C:\ProgramData\hmailserver-firstboot.done, then deletes itself and its script
It runs only once, so there is nothing to turn off. Every start after that, Windows starts MariaDB and hMailServer.
Troubleshooting
hMailServer Administrator cannot connect, or hmailserver-firstboot.done is missing
The first-boot task may still be running: give it a minute and check again. Its log shows how far it got:
Get-Content C:\ProgramData\hmailserver-firstboot.log
"Invalid user or password" in hMailServer Administrator
Copy the password from hmailserver.admin.password= in C:\ProgramData\hmailserver-credentials.txt (Step 4). If you changed it, the file still holds the first one.
Mail to other domains stays in the queue
Azure blocks outbound port 25 (Step 8): set up an SMTP relay on port 587. The queue is under Status > Delivery queue.
Mail from outside does not arrive
- Check that the Azure network security group allows TCP 25 in from anywhere (Step 1)
- Check your MX and A records (Step 7), for example with
Resolve-DnsName -Type MX example.com - Check that the domain and the account exist and are enabled (Step 6)
A client cannot sign in
Clients must use TLS: port 587 with STARTTLS for sending, 993 or 995 for reading. Plain-text sign-in is refused by design. After several failed sign-ins, auto-ban blocks the client's address for a while: see Settings > Advanced > Auto-ban and the IP Ranges it creates.
Forgot the Windows password
Use Reset password on the VM's page in the Azure portal.
Security Recommendations
- Keep Remote Desktop restricted to your own address (Step 1), or use Azure Bastion
- Open only the ports your users need. Port 25 must be open to everyone to receive mail; restrict 587, 993 and the others to your users' addresses where you can
- Never turn off "Require SMTP authentication" for the Internet range: that would make the server an open relay
- Keep the credentials file private. It is readable by administrators only; do not copy it to shared places
- Change the administrator password (Settings > Advanced > Administration password) if others can read this VM's file, and keep auto-ban on
- Back up
C:\ProgramData\hMailServerand the database (for examplemariadb-dumpwith the root password, or Azure Backup or disk snapshots)

Support
cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours, covering deployment, Remote Desktop access, domains and accounts, DNS, smart hosts, certificates and upgrades.
- Email: support@cloudimg.co.uk
- Website: www.cloudimg.co.uk
- Product Catalogue: www.cloudimg.co.uk/products
- User Guides: www.cloudimg.co.uk/guides
hMailServer is free software licensed under the GNU Affero General Public License version 3; MariaDB Server is licensed under the GNU General Public License version 2. All product and company names are trademarks or registered trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.