Deployment guide

Dovecot

Overview

Dovecot is one of the most widely deployed open source IMAP and POP3 servers, known for its security focus, standards compliance and performance. It runs as a headless daemon, administered through the configuration files in /etc/dovecot and the doveadm command line.

This SecureAnyCloud image runs Dovecot 2.3.21 on Ubuntu 24.04 on Azure as a self-contained, secure-by-default single-node mail store. It installs the Ubuntu 24.04 archive packages dovecot-core, dovecot-imapd, dovecot-pop3d and dovecot-lmtpd (dual licensed MIT and LGPL 2.1). One virtual mailbox keeps its mail in Maildir format under a dedicated unprivileged vmail account, and delivery over LMTP means the setup works end to end with no external dependency.

No default credential. On the first boot of every VM, dovecot-firstboot.service runs once. It generates a per-instance mailbox password, hashes it into the Dovecot password database, regenerates the TLS private key and certificate, and writes the plaintext login to /root/dovecot-credentials.txt (mode 0600, root only). The captured image ships no certificate, no password and only an empty password database, so no mailbox can authenticate until first boot provisions the instance.

No plaintext authentication over the network. Dovecot is configured with disable_plaintext_auth = yes and ssl = required. A remote client's plaintext LOGIN on the non-TLS ports (143 and 110) is refused until the connection is upgraded with STARTTLS. IMAP over implicit TLS (993) and POP3 over implicit TLS (995) are the recommended client ports. Only the virtual mailbox user can authenticate, because system and shell accounts are excluded from mail login.

What you get:

  • Dovecot 2.3.21 from the Ubuntu 24.04 archive (dovecot-core, dovecot-imapd, dovecot-pop3d, dovecot-lmtpd), running under systemd as dovecot.service
  • A self-contained single-node mail store: one virtual mailbox in Maildir format under a dedicated unprivileged vmail account, with local delivery over LMTP
  • IMAP over TLS on 993 and with STARTTLS on 143, and POP3 over TLS on 995 and with STARTTLS on 110
  • A per-instance mailbox password and a fresh TLS key and certificate generated on first boot and documented in /root/dovecot-credentials.txt (0600), so no image ever ships a usable or default credential
  • Plaintext authentication disabled on non-TLS connections (disable_plaintext_auth = yes, ssl = required)
  • An Ubuntu 24.04 LTS base with the latest security patches applied at build time and unattended security upgrades kept enabled
  • The Azure Linux Agent for cloud integration and SSH key injection
  • 24/7 SecureAnyCloud support with a guaranteed 24-hour response SLA

Prerequisites

You need an active Azure subscription, an SSH public key, a VNet and a subnet in the target region. You also need a subscription to the Dovecot listing on Azure Marketplace.

Configure the Network Security Group (NSG) to allow TCP 22 (admin), TCP 993 (IMAPS) and TCP 995 (POP3S) for secure client access. Optionally allow TCP 143 (IMAP with STARTTLS) and TCP 110 (POP3 with STARTTLS).

Recommended VM size: Standard_B2s (2 vCPU, 4 GB RAM) is a comfortable starting point for a small mailbox server. Scale up for more mailboxes, larger mail volumes or higher concurrency.

1

Deploy from the Azure Portal

Search Marketplace for Dovecot, select the SecureAnyCloud publisher, and click Create.

Configure the NSG to allow TCP 22 for administration and TCP 993 and TCP 995 for secure IMAP and POP3 access. Assign a public IP so remote mail clients can connect.

2

Deploy from the Azure CLI

RG="mail-prod"; LOCATION="eastus"; VM_NAME="dovecot1" IMAGE_URN="sac1647283583153:dovecot-ubuntu-24-04:default:latest" az group create --name "$RG" --location "$LOCATION"
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn sac1647283583153:dovecot-ubuntu-24-04:default:latest
az vm create --resource-group "$RG" --name "$VM_NAME" \
  --image "$IMAGE_URN" --size Standard_B2s \
  --admin-username azureuser --generate-ssh-keys --public-ip-sku Standard
# secure IMAP (993), secure POP3 (995), and the STARTTLS ports (143, 110)
az vm open-port --resource-group "$RG" --name "$VM_NAME" --port 993 --priority 1001
az vm open-port --resource-group "$RG" --name "$VM_NAME" --port 995 --priority 1002
az vm open-port --resource-group "$RG" --name "$VM_NAME" --port 143 --priority 1003
az vm open-port --resource-group "$RG" --name "$VM_NAME" --port 110 --priority 1004
3

Wait for first boot to finish

On the first boot of every VM, dovecot-firstboot.service runs once. It generates the per-instance mailbox password, hashes it into the Dovecot password database and regenerates the TLS private key and certificate. It then writes the plaintext login to /root/dovecot-credentials.txt and starts Dovecot.

Allow about 20 seconds after the VM first becomes reachable.

4

Confirm the service is running

SSH in, confirm that Dovecot is active and inspect its effective configuration.

sudo systemctl is-active dovecot
sudo doveconf -n | head -30
5

Read the per-instance mailbox login

The mailbox password is unique to this VM. First boot writes it to a root-only file, so read it with elevated privileges:

sudo cat /root/dovecot-credentials.txt

The file contains the mailbox username (mailbox@localhost), the per-instance password, and the IMAP host and ports. Store it somewhere safe.

6

Inspect the TLS mail listeners

Dovecot serves IMAP on 143 (STARTTLS) and 993 (implicit TLS). It serves POP3 on 110 (STARTTLS) and 995 (implicit TLS). Check the listeners and the TLS settings:

sudo ss -tlnp | grep -E ':(143|993|110|995|24) ' | sort
sudo doveconf disable_plaintext_auth ssl

With disable_plaintext_auth = yes and ssl = required, a remote client's plaintext authentication on 143 or 110 is refused until the connection is upgraded with STARTTLS.

7

Verify the mailbox login end to end

The image ships a self-contained round-trip check. It connects over implicit TLS on 993 and confirms that a wrong password is rejected and the per-instance password is accepted. It then selects the INBOX, delivers a message over LMTP and reads it back over IMAP.

echo | sudo openssl s_client -connect 127.0.0.1:993 -brief 2>&1 | grep -Ei 'protocol|cipher|verify|subject'
sudo python3 /usr/local/sbin/sac-dovecot-roundtrip.py

The final OK full: line confirms the whole path works: implicit TLS on 993, a wrong password rejected, the per-instance password accepted, the INBOX selectable, and an LMTP-delivered message read back over IMAP.

The hardened configuration at a glance:

  • The password database is a root-readable Dovecot password file with a SHA512-hashed per-instance password.
  • The TLS certificate and key are unique to this VM and owned by root.
  • The system PAM login path is disabled, so only the virtual mailbox can authenticate.
  • Plaintext authentication is refused on non-TLS connections.
8

Connect a mail client

Point any standards-compliant IMAP or POP3 client at the VM public IP. Use the mailbox username and the per-instance password from the credentials file.

  • IMAP over TLS: host <vm-ip>, port 993, SSL/TLS, username mailbox@localhost, password from the file
  • POP3 over TLS: host <vm-ip>, port 995, SSL/TLS, same username and password
  • IMAP or POP3 with STARTTLS: ports 143 or 110, connection security STARTTLS

The TLS certificate is self-signed and unique to this VM, so your client will prompt you to trust it. Step 10 shows how to replace it with a certificate for your own domain.

9

Add more mailboxes

Generate a hashed password with doveadm pw, append a line to the password file, and reload Dovecot. Each line has the format user:hash:uid:gid::home::, with the vmail uid and gid (5000).

# generate a hash for a new mailbox (you will be prompted for the password)
HASH=$(doveadm pw -s SHA512-CRYPT -p '<new-password>')
echo "alice@<your-domain>:${HASH}:5000:5000::/var/vmail/alice@<your-domain>::" \
  | sudo tee -a /etc/dovecot/sac-users
sudo systemctl reload dovecot
10

Install a TLS certificate for your domain

For production, replace the self-signed per-instance certificate with a certificate for your own domain, for example one from Let's Encrypt. Then point Dovecot at it.

sudo certbot certonly --standalone -d mail.<your-domain>
sudo sed -i 's#^ssl_cert = .*#ssl_cert = </etc/letsencrypt/live/mail.<your-domain>/fullchain.pem#' /etc/dovecot/conf.d/99-sac.conf
sudo sed -i 's#^ssl_key = .*#ssl_key = </etc/letsencrypt/live/mail.<your-domain>/privkey.pem#' /etc/dovecot/conf.d/99-sac.conf
sudo systemctl restart dovecot
11

Add an MTA to send and receive mail

Dovecot is the mailbox store (IMAP and POP3) and the local delivery agent (LMTP). To exchange mail with the outside world, put a mail transfer agent such as Postfix in front of it. Postfix delivers inbound mail to Dovecot over LMTP.

Configure Postfix for your own domain and DNS (MX, SPF, DKIM and DMARC records). Keep outbound relay restricted to authenticated submission.

# example only — install and configure Postfix for your own domain
sudo apt-get install -y postfix
sudo postconf -e "mailbox_transport = lmtp:inet:127.0.0.1:24"
sudo postconf -e "myhostname = mail.<your-domain>"
sudo systemctl restart postfix

Note that Azure blocks outbound SMTP on port 25 by default for most subscriptions. To send mail directly, request an outbound port 25 exception from Azure, or relay outbound mail through a smart host on port 587. Inbound mail and IMAP or POP3 access are unaffected.

12

Support and Licensing

Dovecot Community Edition is dual licensed under the MIT and LGPL 2.1 licenses, both permissive and redistributable. SecureAnyCloud provides the packaging, hardening and Azure integration, with 24/7 support and a guaranteed 24 hour response SLA.

Trademark notice. SecureAnyCloud is not affiliated with or endorsed by the Dovecot project or Open-Xchange. This image packages the open source Dovecot software for convenient deployment on Azure.

Deploy on Azure

Find Dovecot on Ubuntu 24.04 LTS by SecureAnyCloud on the Azure Marketplace and click Create, or deploy from the Azure CLI as shown above.

Need Help?

Contact SecureAnyCloud support at sales@secureanycloud.com for deployment assistance, configuration guidance, or licensing questions.

Deploy on Azure

Launch Dovecot on Ubuntu 24.04 LTS on Azure with 24/7 support from SecureAnyCloud.

View this image

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com

Deploy on Azure