Restrict or block Postfix Sender address

This article describes how to configure Postfix to restrict mails from a specific sender or domain.

Firstly edit your /etc/postfix/ file, and add the following:

smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access

Next create the file /etc/postfix/sender_access, below is an example:

[email protected]  REJECT
[email protected] OK REJECT

Now you need to create a hash file:

sudo postmap /etc/postfix/sender_access

Finally reload the postfix configuration

sudo systemctl reload postfix.service