5

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?

2
  • Write a policy daemon that returns something like "REDIRECT [email protected]" if it can't find the recipient's address in PostgreSQL, and add a transport entry that return HOLD for [email protected]. Make sure that rewriting is done before reject_unlisted_recipient gets invoked. And be aware that a REDIRECT affects the whole message. EDIT: You might be able to return HOLD from within the policy daemon without going through the rewrite steps. Jan 15, 2014 at 7:28
  • Can you give me an example? I wouldn't know how to write a policy daemon, since I've never done it.
    – josh
    Jan 16, 2014 at 2:36

1 Answer 1

2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .