Hi
Yes there is a way.
A before queue filtering is when the smtp client is still connected so you could send SMTP code but if you want an external script you have to do a "Postfix After-Queue Content Filter "
You can find more information here :
http://www.postfix.org/FILTER_README.html
This is the idea :
incoming mail -> postfix:25 -> external script -> postfix:10025 -> outgoing mail
The external script do not answer 0 or 1 but a normalised exit code like theses :
EX_OK 0 /* successful termination : transmit */
EX_UNAVAILABLE 69 /* service unavailable : bounce */
EX_SOFTWARE 70 /* internal software error : bounce */
EX_TEMPFAIL 75 /* temp failure. postfix will retry. */
EX_NOPERM 77 /* permission denied : bounce */
Regards
Victor d'Agostino