Restricting recipient emails in postfix

Had a requirement today to restrict emails from our postfix server to only to some specific domains/ email addresses. It turned out to be pretty simple

At the end of /etc/postfix/main.cf just add

smtpd_recipient_restrictions =
   check_recipient_access hash:/etc/postfix/access
   permit_auth_destination
   reject

and at the end of /etc/postfix/access add the domain names/ email addresses which can accept emails

kamalmeet.com OK
abcd@gmail.com OK

Now update postfix db

postmap hash:/etc/postfix/access

and finally restart service

service postfix restart

That’s it