Here is my situation:
I have a Linux server (running Sendmail) acting as my gateway. I have a Windows server connected to the LAN running SAV4SMTPGW (Symantec AntiVirus for SMTP Gateways).
I would like Sendmail to check for the presence of a custom header and if it is not present, add it and try to send the message to SAV4SMTPGW. SAV4SMTPGW will scan the message and send the message back to Sendmail via SMTP (adds 2 extra hops to the message delivery).
If the custom header is already present when Sendmail receives a message (or SAV4SMTPGW is down for some reason), then deliver the message to its destination (if address locally, then deliver to Cyrus; if address externally, then deliver to the proper MX).
PS - I use SMTP with Authentication and TLS so my users can send email for anywhere they want and I can't lose that functionality.