your suggestion regarding the SMTP proxy worked. I used proxysmtp-1.2.1 to implement outgoing and incoming mail filtering. The trick is to switch around the ports. The proxy is set to listen on port 25 whereas the actual MTA is listening on another port. This way the proxy will be able to filter both incoming and outgoing mail. Once the proxy is finished processing the message it is simply forwarded to the actual MTA.
The problem was that I couldn't simply generate a copy of the message with the 'mail' utility as this would cause an infinite loop to occur. Instead the filtering script had to insert the message into the target user's spool file directly.
echo "From username@domain `date`" >> /var/spool/mail/targetuser
echo "Return-Path: <username@domain>" >> /var/spool/mail/targetuser
cat tmpmessage_file >> /var/spool/mail/targetuser
well thats the short of it anyway. Perhaps not the most elegant solution but it works
The problem could have been handled better within the application itself. However, I am building around legacy modules (no source code available) which only allows one email to be specified in it's configuration files, hence the need for outgoing mail filtering.
Regards