I read that you want to host a second instance of HMS on a different server than your primary HMS host, this second HMS would be listed in the DNS with an MX having a higher Priority number than your primary host. You want this backup server to be listening for connections on port 25 only when the secondary server detects that connections to the primary server cannot be made.
Monitoring software can do all of that. I use Servers Alive (https://www.woodstone.nu/salive/download.php
). This software can monitor an SMTP port and alarm when the either a connection cannot be made or the protocol response to connection is incorrect. It can also trigger a command or a start a service on the local system.
The free version of Servers Alive allows for ten monitoring points, or checks. It is not time-limited.
So, using Servers Alive, create a monitor using the built-in SMTP protocol definition. Servers Alive will connect to the remote host and look for "220" to be returned, if it sees this data in the response, it will tidy up by sending a QUIT, close the connection, and mark the server as up. If it doesn't see it, it will close the connection and mark the server down.
Next, Servers Alive, based on the primary HMS server being transitioned to down, it can trigger either a start of the primary HMS server, or you can specify a command such as SC.EXE to resume the service from paused.
The only thing left to engineer is when to stop or pause the the secondary server. Presumably you would only want to do that then the queue of the secondary server is drained, so that you don't wind up sequestering undelivered messages when the primary server comes back up.
This is going to require a little more ingenuity. Servers Alive can also execute a check conditionally based on whether a parent check is up or down, so you would create a second check that is only evaluated based on the primary server being up. The second check runs a utility to determine the number of messages in queue. If the queue length is zero, the check stops or pauses the secondary HMS server.
I wrote a small utility to serve this purpose. It is posted here: https://www.hmailserver.com/forum/viewt ... 20&t=30859