I'm going to throw all this into one mail as it's all related for me. I'm moving from SMail (which has grown over the last 7 odd years) to Exim for mail transport here and have hit a couple of snags, and am hoping that the wheel has already been invented.
Our current system (so you know what I'm trying to do), puts all incoming mail into one queue. A script then picks it up message at a time, does various checks:
Old domain - message dropped or let through
Spam - message marked
Virus - message dropped or let through
Global alias file - Message let through or custom message returned
All of above logged to a database as well as size, in/out, to/from
Check for attachments and hold - send message to local user (if sender or recipient)
Save sample of mail for human Spam sorting :-)
At the end of this the message (assuming it hasn't been dropped or deferred) is placed into an outgoing queue and delivered.
As you can see there are a whole load of different functions handled by the script. I've got the Spam and virus checking covered as well as dropping the old domain but have some queries regarding the rest.
First question: How can I run a script from a router (well, I think it would be a transport called from a router) and use the return value to decide whether to let the mail through to the next router, drop it or bounce it (with a custom message).
Second question: How can I log things like Spam and virus results (Spam score, virus name)? I'm using sa-exim for SpamAssassin and exiscan for clamdav
Third question: Given that things are going to be logged at different points, what is the best method of tying them together? Is it the message id?
I'm sure these have all been covered before, but can't find examples :-( Any pointers gratefully received.
Thanks
Kevin