Postfix supports filtering mail through a filter that acts like an SMTP server. This is how ProxSMTP was designed. Postfix supports before-queue and after-queue filters. This document will describe the latter. For more details on why and how this all works, read the above links on the Postfix site.
Put the following lines in your Postfix main.cf file:
content_filter = filter:[127.0.0.1]:10025 receive_override_options = no_address_mappings
The content_filter tells Postfix to send all mail through the service called 'scan' on port 10025. We'll set up proxsmtpd to listen on this port later.
Next we add the following to the Postfix master.cf file:
# SMTP filter (used by content_filter) filter unix - - n - 16 smtp -o smtp_send_xforward_command=yes -o smtp_enforce_tls=no # For injecting mail back into postfix from the filter 127.0.0.1:10026 inet n - n - 16 smtpd -o content_filter= -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks -o smtpd_helo_restrictions= -o smtpd_client_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks_style=host -o smtpd_authorized_xforward_hosts=127.0.0.0/8
Make sure there's no spaces around the equal signs or commas in the text you added. The first 2 lines create the 'filter' service. The rest set up a service for accepting mail back into postfix. All the options prevent a mail loop as well as relax address checking and the like, since that's already been done.
Specify the OutAddress option in proxsmtpd.conf as 127.0.0.1:10026. Make an appropriate user to run proxsmtpd as. Running as root is not recommended.You can use the User option in proxsmtpd.conf to accomplish that.
Create a filter script. You can use one of the sample scripts as a starting point. Make sure the script runs properly under the user you are running proxsmtpd as (see above). Use the FilterCommand and FilterType options to set the filter.
Now start up proxsmtpd like this:
# proxsmtpd -f /path/to/proxsmtpd.conf
And that's all there is to it. If something's not working, check mail-queues, logs, your script, etc... If you have trouble with proxsmtpd or send me a bug report, be sure to try the debug log mode which can be a valuable aid in figuring things out:
# proxsmtpd -d 4 -f /path/to/proxsmtpd.conf
[Note: You may have to keep this in mind if you're trying out the above setup in a jail, and change the smtpd_authorized_xforward_hosts line accordingly.]