ProxSMTP is a flexible tool that allows you to reject, change or log email based on arbitrary criteria. It accepts SMTP connections and forwards the SMTP commands and responses to another SMTP server. You need to be able to write the filtering scripts that integrate it with your particular needs.