Restrict Postfix Senders

   KB 3659        Last updated on 07/12/2015  

(0 votes)
 - This article is a Community contribution and may include unsupported customizations.
 - This is archive documentation, which means it is not supported or valid for recent versions of Zimbra Collaboration.
 - This article is a Work in Progress, and may be unfinished or missing sections.
  • This setup procedure will set up your server to allow outgoing mails from only the domains configured on the server itself.
  • For example, if your mail domains are and/or for example,, with the configuration presented here, no user registered into the system will be allowed to send mails as if belonging in other domains, as,,, etc....
  • Basically, these modifications "extend" the option "Allow sending email from any address" of the Zimbra, which only works for users in Webmail, to the entire system, including the open RELAY networks and authenticated users.
  • WARNING: The effects of this setting affect the entire system, whether registered users or IP networks declared in zimbraMtaMyNetwork...
  • This setup was tested with Zimbra 5.0.24, 6.0.8 on both Open Source and Network Editions.
  • To make sure that this procedure works, install a fresh Zimbra server using the domain "" and the "admin" user password "123456".
  • To facilitate testing, enable the clear text login option at the Zimbra admin panel.

Complete procedure

  • Become root:
sudo -i
  • Enter into the directory settings:
cd /opt/zimbra/conf
  • Edit the file:
  • ...and, right below the line:
POSTCONF smtpd_sender_restrictions LOCAL postfix_smtpd_sender_restrictions
  • Add the following line, do not forget the tab at the beginning of each line:
POSTCONF smtpd_sender_login_maps FILE
  • Save the file.
  • Set the sender_restriction using :
zmlocalconfig -e postfix_smtpd_sender_restrictions=reject_authenticated_sender_login_mismatch
  • Now make the files declared in the file
  • The file:
  • Write:
  • Now make the exceptions file, which you can declare a random e-mail sender address that a user can have, something like a bypass.
vim exceptions-db
  • Examples of exceptions (you can leave the file empty): admin
  • Run:
/opt/zimbra/postfix/sbin/postmap exceptions-db
  • Now you need to get two pieces of information, its server_host (referring to LDAP) and the bind_pw of the user "uid=zmpostfix,cn=appaccts,cn=zimbra". For that, seek and record the data from the file "/opt/zimbra/conf/", and make the file "/opt/zimbra/conf/" as follows:
grep server_host /opt/zimbra/conf/
  • And:
grep bind_pw /opt/zimbra/conf/
  • Make the file
vim /opt/zimbra/conf/
  • With (Adjust the server_host and bind_pw according to the output of the "grep" command above):
server_host = ldap://
server_port = 389
search_base =
query_filter = (&(|(uid=%s)(zimbraMailDeliveryAddress=%s)(zimbraMailAlias=%s)(zimbraMailCatchAllAddress=%s))(zimbraMailStatus=enabled))
result_attribute = uid,zimbraMailDeliveryAddress,zimbraMailForwardingAddress,zimbraPrefMailForwardingAddress,zimbraMailCatchAllForwardingAddress
version = 3
start_tls = yes
tls_ca_cert_dir = /opt/zimbra/conf/ca
bind = yes
bind_dn = uid=zmpostfix,cn=appaccts,cn=zimbra
bind_pw = XXXXXXXXXX
timeout = 30
  • Make some final adjustments:
chown zimbra: postfix_sender_* exceptions-db*
  • Activate the changes:
su - zimbra
zmmtactl restart
  • Test your changes:

Encode the "admin" e-mail address and password with the base64:

perl -MMIME::Base64 -e 'print encode_base64("\000admin\\000123456")'

Test the smtp via telnet

$ telnet 25
Connected to
Escape character is '^]'.
220 ESMTP Postfix
250-SIZE 10240000
250 DSN
235 2.7.0 Authentication successful
mail from:
250 2.1.0 Ok
rcpt to:
553 5.7.1 <>: Sender address rejected: not owned by user
  • Well done!
Verified Against: Zimbra Collaboration 7.0, 6.0 Date Created: 04/16/2014
Article ID: Date Modified: 07/12/2015

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