Is it possible to hold rejected messages in a queue

postfix

I have a custom Postgresql backend for my virtual tables in Postfix, but there are times when a user's email isn't correctly configured and is responded to with a User unknown in virtual alias table error. I would like to be able to hold such messages in a queue for review and possibly sending to the correctly configured email later. Is it possible to configure Postfix to send these rejected emails to a queue?

Edit: The best solution I've found is to use defer_if_reject in main.cf, but if I only wanted to defer_if_reject when the email address isn't found in the virtual email addresses table, then how could I accomplish this? And would it be possible to forward only this kind of message to a separate queue rather than the generic deferred queue?

Best Answer

If you OK with defer_if_reject solution then you can add this rule on smtpd_recipient_restriction

defer_if_reject reject_unlisted_recipient

For more info checks the official documentation


For HOLD solution, you can search postgresql query to return value HOLD if account doesn't exist in table. Quick googling reveals that Postgre have feature WHERE NOT EXISTS (check this page for some examples). (Sorry I don't familiar with Postgre :))

So, in smtpd_recipient_restriction define

check_recipient_access pgsql:/path/to/pgsql/config

For the content of /path/to/pgsql/config, please consult this man page

Related Topic