Immediately send Postfix messages to HOLD

For a project, I needed to find some way to purposefully and immediately throw sent messages into the Postfix HOLD queue so they could be released programmatically.

On Debian, you’ll need the postfix-pcre package, and then:

In /etc/postfix/
header_checks = pcre:/etc/postfix/header_checks

And then in /etc/postfix/header_checks:
/^X-My-Custom-Header: .*YES/ HOLD

In your application, for applicable messages you can set X-My-Custom-Header: YES and the messages will immediately go into HOLD.