Restricting Users in Zimbra to Send Email in Certain Domains


Issue:

Recently, we got a request from one of our customers to restrict sending emails to outside domain for some users. They will be able to send emails to their local domain only, but can receive all the emails from outside or local domain.

Solution:

We can achieve the desired restriction by modifying postfix configuration in Zimbra. The step by step procedure is shown below.

Step 1: Open the below file and add the line at the top.
zimbra@mail:~$ vim /opt/zimbra/conf/zmconfigd/smtpd_sender_restrictions.cf
check_sender_access lmdb:/opt/zimbra/common/conf/restricted_senders

Step 2: Open the below file and add the lines before RESTART mta
vim /opt/zimbra/conf/zmconfigd.cf
POSTCONF    smtpd_restriction_classes  local_only
POSTCONF    local_only  FILE  postfix_check_recipient_access.cf
RESTART mta

Step 3: Create a file /opt/zimbra/conf/postfix_check_recipient_access.cf and add the following line.
zimbra@mail:~$ vim /opt/zimbra/conf/postfix_check_recipient_access.cf
check_recipient_access lmdb:/opt/zimbra/common/conf/local_domains, reject

Step 4: Create a file /opt/zimbra/common/conf/restricted_senders and add all the users whom the restriction will be applicable.
zimbra@mail:~$ vim /opt/zimbra/common/conf/restricted_senders
user@mydomain.com           local_only

Step 5: Create a file /opt/zimbra/common/conf/local_domains and add all the domains where “restricted users” can send emails.
vim /opt/zimbra/common/conf/local_domains

mydomain.com                    OK
otheralloweddomain.com     OK


Step 6: Run following commands.
zimbra@mail:~$ postmap /opt/zimbra/common/conf/restricted_senders
zimbra@mail:~$ postmap /opt/zimbra/common/conf/local_domains
zimbra@mail:~$ zmmtactl stop
zimbra@mail:~$ zmmtactl start

In the same way, we can also restrict users to send emails to any domain including local domain. In that case, we have to remove mydomain.com from the file /opt/zimbra/common/conf/local_domains.

Comments

Popular posts from this blog

Install a Comodo/Sectigo Domain Validation SSL certificate in Zimbra

Adding DKIM record (1024 bit) in Zimbra

Recipient Limit of a Message in Zimbra