Restricting Users to Send Emails Locally and Externally

We, sometimes, need to block users to send emails both the internal and external destinations. For example, you are running an email account for receiving CVs only. However, you don’t have to reply them from this account. All the feedback email is maintained from another account. In that case, you may block the user to send emails. It will not impact in email receiving status.

Please follow below guideline to achieve our goal.

Goal: Restricting users to send emails to all internal and external domains.

 

Resolution:

Step 1: Open the file smtpd_sender_restrictions.cf and add the below line at the top.

root@mail:~# vim /opt/zimbra/conf/zmconfigd/smtpd_sender_restrictions.cf

%%contains VAR:zimbraMtaSmtpdSenderRestrictions check_sender_access lmdb:/opt/zimbra/common/conf/restricted_senders%%

 

Step 2: Execute the below line as Zimbra user.

zimbra@mail:~$ zmprov ms `zmhostname` +zimbraMtaSmtpdSenderRestrictions "check_sender_access lmdb:/opt/zimbra/common/conf/restricted_senders"

 

Step 3: Open the file zmconfigd.cf and add below line before “RESTART MTA”.

root@mail:~# vim /opt/zimbra/conf/zmconfigd.cf

POSTCONF    smtpd_restriction_classes  local_only

POSTCONF    local_only  FILE  postfix_check_recipient_access.cf

 

Step 4: Create a new file as postfix_check_recipient_access.cf and add the below line.

root@mail:~# touch /opt/zimbra/conf/postfix_check_recipient_access.cf

root@mail:~# vim /opt/zimbra/conf/postfix_check_recipient_access.cf

check_recipient_access lmdb:/opt/zimbra/common/conf/local_domains, reject

 

Step 5: Create a file named restricted_senders and enter the blocked user list as below.

root@mail:~# touch /opt/zimbra/common/conf/restricted_senders

root@mail:~# vim /opt/zimbra/common/conf/restricted_senders

blockeduser@domain.com            local_only

 

Step 6: Create another file named local_domain and keep this file empty.

root@mail:~# touch /opt/zimbra/common/conf/local_domains

As we keep this file empty, restricted users can not send emails towards external, internal domains as well as self.

 

Step 7: Provide necessary permissions and ownerships to the created files.

root@mail:~# chown zimbra:zimbra /opt/zimbra/conf/postfix_check_recipient_access.cf

root@mail:~# chmod 644 /opt/zimbra/conf/postfix_check_recipient_access.cf

root@mail:~# chown :zimbra /opt/zimbra/common/conf/restricted_senders

root@mail:~# chmod 775 /opt/zimbra/common/conf/restricted_senders

root@mail:~# chown :zimbra /opt/zimbra/common/conf/local_domains

root@mail:~# chmod 775 /opt/zimbra/common/conf/local_domains

 

Step 8: Create the database and update it for the newly created files as a Zimbra user.

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

 

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