sudo apt-get install postfwd
sudo nano /etc/postfix/postfwd.cf
Clear any default examples and add the following rule to limit authenticated users to 99 emails per day:
# Limit authenticated users to 99 emails per 24 hours (86400 seconds)
id=RATE_LIMIT_USER; \
sasl_username=~./; \
action=rate(sasl_username/99/86400/REJECT You have exceeded your daily quota of 99 emails);
sudo systemctl restart postfwd
sudo systemctl enable postfwd
sudo nano /mailinabox/setup/postfix.sh
Scroll down until you find the section configuring smtpd_sender_restrictions. It typically looks like this:
tools/editconf.py /etc/postfix/main.cf \
smtpd_sender_restrictions="permit_sasl_authenticated,permit_mynetworks,reject_non_fqdn_sender,reject_unknown_sender_domain,reject_unlisted_sender"
Modify that block to append check_policy_service inet:127.0.0.1:10040 right after permit_sasl_authenticated. This ensures postfwd checks authenticated users before they are completely cleared to send:
tools/editconf.py /etc/postfix/main.cf \
smtpd_sender_restrictions="permit_sasl_authenticated,check_policy_service inet:127.0.0.1:10040,permit_mynetworks,reject_non_fqdn_sender,reject_unknown_sender_domain,reject_unlisted_sender"
Run the Mail-in-a-Box setup script to safely regenerate your live Postfix configurations with the new policy rule injected.