Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Write a policy daemon that returns something like "REDIRECT hold@example.com" if it can't find the recipient's address in PostgreSQL, and add a transport entry that return HOLD for hold@example.com. 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. –  Stefan Förster Jan 15 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. –  Joshua Smock Jan 16 at 2:36

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.