Revision as of 22:30, 1 February 2010 by Cfremon (talk | contribs) (Adding unsupported template and changes to formatting)

Restrict Postfix Recipients

  • This will show how you can modify postfix to restrict who can send to certain addresses in your domain such as distribution lists like
  • These changes will most likely not persist between upgrades! (UPDATE: Just updated to 4.0.4 and the only thing that was wiped out was the change to /opt/zimbra/conf/ Also, permissions on files created in /opt/zimbra/postfix/conf got changed.)
  • This method can be spoofed by forging the MAIL FROM: header (so mail appears to originate from within the domain), so it isn't foolproof, but it works for basic needs.


  • Create a 'permitted senders' list (as user zimbra) - This is your list of domains and/or users who can email your protected email addresses:
vi /opt/zimbra/postfix/conf/permitted_senders

[paste in contents below editing as required]

localhost               OK            OK     OK  OK
  • Create a 'protected recipients' list (as user zimbra) - This is your list of email addresses that may only receive email from 'permitted senders'
vi /opt/zimbra/postfix/conf/protected_recipients

[paste in contents below editing as required]         permitted_senders_list         permitted_senders_list 
  • Create a simple bash script to create postfix DB files (as user zimbra):
vi /opt/zimbra/postfix/conf/update_protected_recipients

[paste in contents below editing as required]

echo "rebuild permitted_senders..."
postmap /opt/zimbra/postfix/conf/permitted_senders
echo "rebuild protected_recipients..."
postmap /opt/zimbra/postfix/conf/protected_recipients
  • Make new script executable, then run it
chmod 755 /opt/zimbra/postfix/conf/update_protected_recipients
  • You should now see permitted_senders.db and protected_recipients.db in the directory
  • Add necessary settings to /opt/zimbra/postfix/conf/
vi /opt/zimbra/postfix/conf/

[add these items to the file - note permitted_senders_list must match value in protected_recipients]

permitted_senders_list = check_sender_access hash:/opt/zimbra/postfix/conf/permitted_senders, reject
smtpd_restriction_classes = permitted_senders_list
 **Note this change to the won't survive upgrades. Be sure to save a copy of your file**
  • Now add your new restriction to the top of
vi /opt/zimbra/conf/

[paste this into the first line of the file, above any other settings]

check_recipient_access hash:/opt/zimbra/postfix/conf/protected_recipients
  • Reload postfix to activate settings:
postfix reload

Note 3 from talk: files ownership should be set to root:postfix before reloading postfix. This avoids annoying warning messages in logfile.

Test it out

  • Test your settings via telnet:

Enter command:

telnet 25

You will see:

Connected to
Escape character is '^]'.
220 ESMTP Postfix

Enter command:


You will see:


Enter command:


You will see:

250 Ok

Enter command:


You will see:

554 <>: Recipient address rejected: Access denied
221 Bye
Connection closed by foreign host.
  • That's it. If you need to protect new distribution lists or emails, or add new senders, just edit and re-run the update script, then reload postfix.

Additional Resources

Verified Against: unknown Date Created: 11/3/2006
Article ID: Date Modified: 2010-02-01

Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search