RestrictPostfixSenders

Revision as of 03:02, 28 July 2010 by Martinx (talk | contribs)

PROCEDURE IN REVIEW

Restrict Postfix Senders

  • 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 @company.com and @company.co.uk, with the configuration presented here, no user registered into the system will be allowed to send mails as if belonging in other domains, as @gmail.com, @microsoft.com, @sapo.pt, 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.7 on both Open Source and Network Editions.

Complete procedure

  • Become root:
sudo -i
  • Enter into the directory settings:
cd /opt/zimbra/conf
  • Edit the zmmta.cf file:
vim zmmta.cf
  • ...and, right below the line:
POSTCONF local_header_rewrite_clients permit_mynetworks,permit_sasl_authenticated
  • Add the following two lines, do not forget the tab at the beginning of each line:
POSTCONF smtpd_sender_restrictions FILE postfix_sender_restrictions.cf
POSTCONF smtpd_sender_login_maps FILE postfix_sender_login_maps.cf
  • Save the zmmta.cf file.
  • Now make the files declared in the file zmmta.cf.
  • The postfix_sender_restrictions.cf file:
vim postfix_sender_restrictions.cf
  • Write:
reject_authenticated_sender_login_mismatch
  • The postfix_sender_login_maps.cf file:
vim postfix_sender_login_maps.cf
  • Write:
hash:/opt/zimbra/conf/exceptions-db
ldap:/opt/zimbra/conf/ldap-restricrelay.cf
  • 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):
johndoe@otherdomain.com zimbra_login
  • 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/ldap-vam.cf", and make the file "/opt/zimbra/conf/ldap-restricrelay.cf" as follows:
grep server_host /opt/zimbra/conf/ldap-vam.cf
  • And:
grep bind_pw /opt/zimbra/conf/ldap-vam.cf
  • Make the file ldap-restricrelay.cf:
vim /opt/zimbra/conf/ldap-restricrelay.cf
  • With (Adjust the server_host and bind_pw according to the output of the "grep" command above):
server_host = ldap://srvXX.company.com.br:389
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* ldap-restricrelay.cf
  • Activate the changes:
su - zimbra
zmmtactl restart
  • Well done!
Jump to: navigation, search