Currently have a postfix server running as a backup mail server for several different domains. So when the primary mail server goes down, email will go to the backup server (second in the order of MX).
There is a third server in the MX also acting as a backup server in case the second fails.
I want to configure the two backup servers to only deliver the stored email to the primary when it comes back up, otherwise retain on the mail queue.
I know I could do this by adding the primary server to a transport file. However in this case I can’t use a transport file and the servers will use the MX records from DNS.
So I want to configure the backup server to only try the first server in the MX order and not the others.
Can this be done?
Yes you can do this, but you would need split zone DNS or an additional local DNS server with those zones to provide only that MX to those 2 backup servers... Or use the transport configuration as suggested. Either way you'll need some separate configuration. You could build a DNS resolver in python to only give you a specific MX by priority, but that seems slow and overly complicated given your other 2 options.