pmgcm - Proxmox Mail Gateway Cluster Management Toolkit



pmgcm create

Create initial cluster config with current node as master.

pmgcm delete <cid>

Remove a node from the cluster.

<cid>: <integer> (1 - N)

Cluster Node ID.

pmgcm help [OPTIONS]

Get help about specified command.

--extra-args <array>

Shows help for a specific command

--verbose <boolean>

Verbose output format.

pmgcm join <master_ip> [OPTIONS]

Join a new node to an existing cluster.

<master_ip>: <string>

IP address.

--fingerprint ^(:?[A-Z0-9][A-Z0-9]:){31}[A-Z0-9][A-Z0-9]$

SSL certificate fingerprint.

pmgcm join_cmd

Prints the command for joining an new node to the cluster. You need to execute the command on the new node.

pmgcm promote

Promote current node to become the new master.

pmgcm status [OPTIONS]

Cluster node status.

--list_single_node <boolean> (default = 0)

List local node if there is no cluster defined. Please note that RSA keys and fingerprint are not valid in that case.

pmgcm sync [OPTIONS]

Synchronize cluster configuration.

--master_ip <string>

Optional IP address for master node.


We are living in a world where email becomes more and more important - failures in email systems are just not acceptable. To meet these requirements we developed the Proxmox HA (High Availability) Cluster.

The Proxmox Mail Gateway HA Cluster consists of a master and several slave nodes (minimum one node). Configuration is done on the master. Configuration and data is synchronized to all cluster nodes over a VPN tunnel. This provides the following advantages:

  • centralized configuration management

  • fully redundant data storage

  • high availability

  • high performance

We use a unique application level clustering scheme, which provides extremely good performance. Special considerations where taken to make management as easy as possible. Complete Cluster setup is done within minutes, and nodes automatically reintegrate after temporary failures without any operator interaction.


Hardware requirements

There are no special hardware requirements, although it is highly recommended to use fast and reliable server with redundant disks on all cluster nodes (Hardware RAID with BBU and write cache enabled).

The HA Cluster can also run in virtualized environments.


Each host in a cluster has its own subscription. If you want support for a cluster, each cluster node needs to have a valid subscription. All nodes must have the same subscription level.

Load balancing

It is usually advisable to distribute mail traffic among all cluster nodes. Please note that this is not always required, because it is also reasonable to use only one node to handle SMTP traffic. The second node is used as quarantine host, and only provides the web interface to the user quarantine.

The normal mail delivery process looks up DNS Mail Exchange (MX) records to determine the destination host. A MX record tells the sending system where to deliver mail for a certain domain. It is also possible to have several MX records for a single domain, they can have different priorities. For example, our MX record looks like that:

# dig -t mx

;; ANSWER SECTION:            22879   IN      MX      10

;; ADDITIONAL SECTION:       22879   IN      A

Please notice that there is one single MX record for the Domain, pointing to The dig command automatically puts out the corresponding address record if it exists. In our case it points to The priority of our MX record is set to 10 (preferred default value).

Hot standby with backup MX records

Many people do not want to install two redundant mail proxies, instead they use the mail proxy of their ISP as fallback. This is simply done by adding an additional MX Record with a lower priority (higher number). With the example above this looks like that:            22879   IN      MX      100 mail.provider.tld.

In such a setup, your provider must accept mails for your domain and forward them to you. Please note that this is not advisable, because spam detection needs to be done by the backup MX server as well, and external servers provided by ISPs usually don’t.

However, you will never lose mails with such a setup, because the sending Mail Transport Agent (MTA) will simply deliver the mail to the backup server (mail.provider.tld) if the primary server ( is not available.

Note Any reasonable mail server retries mail delivery if the target server is not available, i.e. Proxmox Mail Gateway stores mail and retries delivery for up to one week. So you will not lose mail if your mail server is down, even if you run a single server setup.

Load balancing with MX records

Using your ISPs mail server is not always a good idea, because many ISPs do not use advanced spam prevention techniques, or do not filter SPAM at all. It is often better to run a second server yourself to avoid lower spam detection rates.

Anyways, it’s quite simple to set up a high performance load balanced mail cluster using MX records. You just need to define two MX records with the same priority. Here is a complete example to make it clearer.

First, you need to have at least 2 working Proxmox Mail Gateway servers ( and configured as cluster (see section Cluster administration below), each having its own IP address. Let us assume the following addresses (DNS address records):       22879   IN      A       22879   IN      A

It is always a good idea to add reverse lookup entries (PTR records) for those hosts. Many email systems nowadays reject mails from hosts without valid PTR records. Then you need to define your MX records:            22879   IN      MX      10            22879   IN      MX      10

This is all you need. You will receive mails on both hosts, more or less load-balanced using round-robin scheduling. If one host fails the other one is used.

Other ways

Multiple address records

Using several DNS MX records is sometimes clumsy if you have many domains. It is also possible to use one MX record per domain, but multiple address records:            22879   IN      MX      10       22879   IN      A       22879   IN      A

Using firewall features

Many firewalls can do some kind of RR-Scheduling (round-robin) when using DNAT. See your firewall manual for more details.

Cluster administration

Cluster administration can be done on the GUI or using the command line utility pmgcm. The CLI tool is a bit more verbose, so we suggest to use that if you run into problems.

Note Always setup the IP configuration before adding a node to the cluster. IP address, network mask, gateway address and hostname can’t be changed later.

Creating a Cluster


You can create a cluster from any existing Proxmox Mail Gateway host. All data is preserved.

  • make sure you have the right IP configuration (IP/MASK/GATEWAY/HOSTNAME), because you cannot change that later

  • press the create button on the GUI, or run the cluster creation command:

    pmgcm create
Note The node where you run the cluster create command will be the master node.

Show Cluster Status

The GUI shows the status of all cluster nodes, and it is also possible to use the command line tool:

pmgcm status
pmg5(1)       master A       1 day 21:18   0.30    80%    41%

Adding Cluster Nodes


When you add a new node to a cluster (using join) all data on that node is destroyed. The whole database is initialized with cluster data from the master.

  • make sure you have the right IP configuration

  • run the cluster join command (on the new node):

    pmgcm join <master_ip>

You need to enter the root password of the master host when asked for a password. When joining a cluster using the GUI, you also need to enter the fingerprint of the master node. You get that information by pressing the Add button on the master node.

Caution Node initialization deletes all existing databases, stops and then restarts all services accessing the database. So do not add nodes which are already active and receive mails.

Also, joining a cluster can take several minutes, because the new node needs to synchronize all data from the master (although this is done in the background).

Note If you join a new node, existing quarantined items from the other nodes are not synchronized to the new node.

Deleting Nodes

Please detach nodes from the cluster network before removing them from the cluster configuration. Then run the following command on the master node:

pmgcm delete <cid>

Parameter <cid> is the unique cluster node ID, as listed with pmgcm status.

Disaster Recovery

It is highly recommended to use redundant disks on all cluster nodes (RAID). So in almost any circumstances you just need to replace the damaged hardware or disk. Proxmox Mail Gateway uses an asynchronous clustering algorithm, so you just need to reboot the repaired node, and everything will work again transparently.

The following scenarios only apply when you really lose the contents of the hard disk.

Single Node Failure

  • delete failed node on master

    pmgcm delete <cid>
  • add (re-join) a new node

    pmgcm join <master_ip>

Master Failure

  • force another node to be master

    pmgcm promote
  • tell other nodes that master has changed

    pmgcm sync --master_ip <master_ip>

Total Cluster Failure

  • restore backup (Cluster and node information is not restored, you have to recreate master and nodes)

  • tell it to become master

    pmgcm create
  • install new nodes

  • add those new nodes to the cluster

    pmgcm join <master_ip>

Copyright © 2007-2020 Proxmox Server Solutions GmbH

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see