A fairly simple method of having postfix send messages through SpamAssassin, and then delivering the messages identified as spam to a separate mailbox:
Configure SpamAssassin as normal in master.cf:
smtp inet n - - - - smtpd -o content_filter=spamassassin 2525 inet n - - - - smtpd -o content_filter=spamassassin spamassassin unix - n n - - pipe user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
Configure Spamassassin to log the status and score in a new header by adding this to /etc/spamassassin/local.cf:
## Add a spamassassin header to all messages so that we can filter them out add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_
And then configure postfix to look for that header and deliver it to an alternate mailbox:
/etc/postfix/main.cf:
header_checks = regexp:/etc/postfix/header_checks
/etc/postfix/header_checks:
/^X-Spam-Status: Yes/ REDIRECT spam@yourdomain.com
Now your messages identified as spam will be sent to spam@yourdomain.com so that you can occasionally check for false positives.
Note that there is more work that goes into setting up SpamAssassin, but there are plenty of howtos around for getting that configured.
Is it possible to redirect to different targets based on originaly targeted domain?
Perfect. Just what I was looking for, thanks!