Zimbra Mail Sending Policy
Appearance
ACTIVATING POLICYD ADDON
su - zimbra
zmprov ms `zmhostname` +zimbraServiceInstalled cbpolicyd +zimbraServiceEnabled cbpolicyd zmlocalconfig -e postfix_enable_smtpd_policyd=yes zmprov mcf +zimbraMtaRestriction "check_policy_service inet:127.0.0.1:10031" zmlocalconfig -e cbpolicyd_log_level=4; zmlocalconfig -e cbpolicyd_log_detail=modules,tracking,policies; zmlocalconfig -e cbpolicyd_module_accesscontrol=1 cbpolicyd_module_checkhelo=1 cbpolicyd_module_checkspf=1 cbpolicyd_module_greylisting=1 cbpolicyd_module_quotas=1 zmcontrol restart
#zmcontrol status Host mail.heromotocorp.biz
cbpolicyd Running
ldap Running
logger Running
mailbox Running
mta Running
snmp Running
spell Running
stats Running
zmconfigd Running
WEB UI ACTIVATION FOR POLICYD MANAGEMENT Run the following command by using root permission cd /opt/zimbra/httpd/htdocs/ && ln -s ../../cbpolicyd/share/webui
Modify file /opt/zimbra/cbpolicyd-2.1.0-beta/share/webui/includes/config.php (vi /opt/zimbra/cbpolicyd-2.1.0-beta/share/webui/includes/config.php) and mark a comment (#) to the line begining with: $DB_DSN and add the following code before line begining with : $DB_USER $DB_DSN="sqlite:/opt/zimbra/data/cbpolicyd/db/cbpolicyd.sqlitedb";
Reload Web UI (http) service with the following command : cd /srv/ wget -c http://devlabs.linuxassist.net/attachments/download/230/cluebringer-snapshot-2.1.x-201205100639.tar.gz tar -zxvf cluebringer-snapshot-2.1.x-201205100639.tar.gz cd cluebringer-snapshot-2.1.x-201205100639/webui/ cp *.php *.css /opt/zimbra/cbpolicyd/share/webui/ su - zimbra -c "zmapachectl restart"
Defining a rate-limit (quota) with cbpolicyd[edit]
By default "quota" or "rate limiting" is enabled, but there is no policy defining how it should behave. The below example adds two policies:
- Rate limit any sender from sending more then 20 emails every 60 seconds. Messages beyond this limit are deferred.
As Zimbra:
- Create a file called rate-limit.sql with the following contents. Note: these two quotas entries will get added as QuotasID 3 and 4, because there are two entries already in the default quotas table, as shown above:
BEGIN TRANSACTION; INSERT INTO "quotas" (PolicyID,Name,Track,Period,Verdict,Data) VALUES (6, 'Sender:user@domain','Sender:user@domain', 60, 'DEFER', 'Deferring: Too many messages from sender in last 60'); INSERT INTO "quotas_limits" (QuotasID,Type,CounterLimit) VALUES(3, 'MessageCount', 20); COMMIT;
- Import the rules into cbpolicyd:
sqlite3 /opt/zimbra/data/cbpolicyd/db/cbpolicyd.sqlitedb < rate-limit.sql
Name : Delivery Per User Track : Select Sender@domain. This means that policy will be applies to each user on the domain Period : The length of time that given in seconds. Ideally is in counts per hour or 3600 seconds Link to policy : Select Default Verdict : The rules that will be apply if it meets the period, such as defer (hold the messages until next time interval) Data : Information that is given if it meets the rule, for example the information is a “Maximum 2 email delivery per minute” or “Maximum 300 emails delivery per hour” Stop processing here : choose Yes, means that rule will not processing another rule Comment : can be filled with anything you like https://mail.heromotocorp.biz:7780/webui/index.php
Reference URL: https://wiki.zimbra.com/wiki/Postfix_Policyd : http://vavai.net/2014/02/zimbra-tips-rate-limit-sending-message-with-policyd/