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/ just add

smtpd_recipient_restrictions =
   check_recipient_access hash:/etc/postfix/access

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

Now update postfix db

postmap hash:/etc/postfix/access

and finally restart service

service postfix restart

That’s it