Linux – Configure postfix to filter email into hold queue

emaillinuxpostfixspam-filter

I would like postfix to send all emails received on SMTP off to an
external process, which will decide whether to allow them through as
normal, or whether to put them into the hold queue (or another
quarantine area), where they have to wait for admin approval.

I was thinking of doing this with an after-queue content filter, which
uses pipe(8) to run a script on each message, and the script itself
will spawn "postsuper -h " if it decides to put the message
on hold.

Then the admin can do postsuper -d or -r to delete or pass the message
on as appropriate.

So, my questions are – a) will this work, and b) is this the best way
to do it? Would a milter or another type of content filter be a better
approach?

Best Answer

This is actually the way MailScanner works, so it might be an idea to have a look at the setup documentation for MailScanner/Postfix here. Basically, all email is sent to a hold queue, MailScanner scans it, and anything that's passes is put into the outbound queue.

Hopefully, ignoring the MailScanner specific parts of the doc, you'll be able to extract the Postfix setup you need.