This requires a new configuration parameter to always defer if the bind address is unavailable. There is plemnty of code to copy from.
On the oher hand, insead of using a tunnel and juggling routes, you could use TLS and AUTH for mail that needs to be sent through B. That code will defer if B is unavailable. # Use [] to suppress MX lookups. relayhost = [host.example.com] # owner root, mode 0600 smtp_sasl_password_maps = username/password for B transport_maps = overrides for direct delivery or some sender_dependent configuration. Wietse