How do I get Postfix to deliver ALL mail to a custom script?
Solution 1:
Take a look at master.cf. There are a lot of services/examples defined there already, it will be a good starting point. Next define virtual_transport and set it to the name you defined in master.cf. For example ( i am using dovecot's LDA at my setups ) :
In master.cf :
dovecot unix - n n - - pipe
flags=DR user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop} -n -m ${extension}
In main.cf :
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
This should get you started :)
Or you can implement it as a check_policy_service filter daemon for the smtpd_recipient_restrictions. Reading the postfix docs is the best place to get you started :)