This article describes how to configure Postfix to restrict mails from a sender, to a recipient, or both.
Restrict Sender
This section describes how to allow/reject a specific sender or a specific domain.


1. Edit the file /etc/postfix/main.cf and add the line below.
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access


2. Create the file /etc/postfix/sender_access and review the example below.
janedoe@acme.local REJECT bugsbunny@acme.com OK acme.com REJECT


3. Type in the command below in a terminal window to create a hash file.
postmap /etc/postfix/sender_access

4. Restart the Postfix or MailScanner service. Learn how to restart services.Restrict Recipient
This section describes how to allow/reject a specific recipient or a specific domain.
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access, reject_unauth_destinations


2. Create the file /etc/postfix/recipient_access and review the example below.
janedoe@acme.local REJECT bugsbunny@acme.com OK acme.com REJECT


3. Type in the command below in a terminal window to create a hash file.
postmap /etc/postfix/recipient_access

4. Restart the Postfix or MailScanner service. Learn how to restart services.Restrict Sender and Recipient
This section describes how to restrict both the sender and recipient. Example usage of this is when you have a private domain which should not be allowed to send to the internet.
smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_access, reject_unauth_destinations smtpd_restriction_classes = local_only local_only = check_recipient_access hash:/etc/postfix/local_domains, reject


4. Type in the command belows in a terminal window to create the hash files.
postmap /etc/postfix/sender_access postmap /etc/postfix/local_domains

5. Restart the Postfix or MailScanner service. Learn how to restart services.Visit the forum to ask for help or to give a comment.
***
Posted on 5/17/2010 and last updated on 5/17/2010
Filed under Postfix



