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

How to set Postfix configuration to cach-all emails in domain but excluding some addresses?

share|improve this question

migrated from stackoverflow.com Apr 11 '11 at 12:41

This question came from our site for professional and enthusiast programmers.

2 Answers 2

If you simply add the addresses you want to exclude from the catchall, they exist, are more specific and are used. Only if the envelope recipient is unknown, the catchall address is used.

If you want to block (reject) certain addresses without processing them at all, I can think of a smtpd_recipient_restriction (Postfix-Documentation).

You would add something like

smtpd_recipient_restrictions = 
    check_recipient_access hash:/etc/postfix/rcp_access

And in the file rcp_access (run postmap rcp_access to create the hashed file)

rejectme@example.com     REJECT


And there is the not optimal way of adding a line like

/^To:.*foo@example.com/    REJECT

to your /etc/postfix/header_checks file.

share|improve this answer
seems to be great idea but it doesn't work –  Kamilos Apr 15 '11 at 9:54
Without further investigation why it doesn't work, I can also think of adding a line to the header_checks file. –  initall Apr 15 '11 at 10:02
OK. If I tests it with my-addr.com/free-email-verification-tool/verify-email-address/… it seems works, but when i sent mail it was delivered. To catch-all I use "@domain.com" in virtual_maps after existings aliases, but maybe is other way? –  Kamilos Apr 15 '11 at 11:10
When you send mail you may receive it because you authenticated or sent within your local net: if this is permitted before the check_recipient_access restriction, it is possible. If you implemented the header_checks method, you have to add a similar line to a smtp_header_checks file. The first one is a filter while receiving mails, the latter a filter when mail is delivered. –  initall Apr 15 '11 at 11:42
You may be right. I will test it later from other location. –  Kamilos Apr 15 '11 at 12:10

Your Answer


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.