In my postfix setup I want to "disable" all incoming mail from a specific TLD domain (in my case, all domains ending with ".info"). My usual way to block domains is using a hashed file in /etc/postfix/rejected_domains, that looks like this

bla.info     REJECT Spam
blubb.info   REJECT More Spam!

and having this piece of configuration in my main.cf file:

# domains to be restricted
smtpd_sender_restrictions = hash:/etc/postfix/rejected_domains
reject_unauth_destinations = hash:/etc/postfix/rejected_domains

My idea to block all of info was adding these rules into the above file:

*.info  REJECT Toooo much spam
.info   REJECT Toooo much spam

Unluckily this does not seem to work.

Using postfix 2.8.5-2~build0.10.04 on Ubuntu LTS 10 here.

1 Answer 1


Hash is for literals (exact matches), you want to use regex or pcre:

as Overmind pointed out, you want to append these if you already have values, you can check you existing values with

postconf smtpd_sender_restrictions
postconf reject_unauth_destinations

Then you can override them with:

postconf -e smtpd_sender_restrictions=pcre:/etc/postfix/rejected_domains
postconf -e reject_unauth_destinations=pcre:/etc/postfix/rejected_domains

contents of /etc/postfix/rejected_domains:

/\.info$/           REJECT All Info Domains

and then postfix reload

  • Thanks for your input, is there no need to postmap the referenced file?
    – Rob
    Oct 13, 2015 at 15:53
  • 3
    Correct, postmap is for hash or lmdb files Oct 13, 2015 at 15:54
  • 2
    Note that this will replace other restriction settings. It's best to edit the file directly.
    – Overmind
    Nov 2, 2016 at 6:33
  • can also catch tld's at helo restrictions if they present a tld.. and as needed..
    – B. Shea
    Jan 10, 2017 at 21:06
  • 1
    Also note: depending on the distribution of postfix, it may or may not have pcre dictionary support. Just install it. (In my case I installed sudo apt install postfix-pcre)
    – B. Shea
    Jan 10, 2017 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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