Is there any way to keep an email in the Postfix mail queue for investigation/debugging purposes? I want delay the delivery and the email to be kept in the queue which let's me check it's contents. After I've done that I would flush the queue and let Postfix deliver it. How can I do this?
If it's not possible for a single email - would it be possible to queue all emails for a while?
The HOLD feature should be sufficient for what you ask for, either use it on a message that is not yet delivered:
Since you cannot know the queue ID in advance and might not be able to see it in the time between postfix queuing the mail and final delivery, I recommend defining the criteria for which messages to hold in advance.
Most
smtpd_*_restrictions
allow providing a map that can automatically mark certain mails for holding. Sample:Release or drop mails from the queue after investigating.
Do not forget to remove the HOLD rule when done (or you accumulate a giant queue).