/go/postfwd generates the rate-limiting rules that Postfwd (a Postfix policy service) uses to stop spam and runaway mail. It reads the limits stored in GoAdmio's databases and writes them as a fresh rule file. It can limit: A message over a limit is rejected with a plain-language reason, such as Sorry, Daily limit exceeded: maximum 1000 messages allowed for domain example.com per day. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.
Quick start
# Rebuild the Postfwd rules
/go/postfwd
Options
None. The limits come from GoAdmio’s databases:
| Setting | Where it is stored | Meaning |
|---|---|---|
ServerLimit |
config.db, Config table, row 1 |
Messages per day for the whole server. |
ExternalLimit |
config.db, Config table, row 1 |
Messages per day from external (non-local) connections. 0 turns the rule off. |
DomainLimit |
config.db, Config table, row 1 |
Messages per day for each sending domain. 0 turns the rule off. |
UserLimit |
config.db, Config table, row 1 |
Messages per hour for each mail login. 0 turns the rule off. |
PostfwdIgnore |
site.db, Site table |
1 exempts the account’s domain and logins from the global domain and login limits. |
PostfwdDomainLimit |
site.db, Site table |
Custom messages per day for an exempt domain. 0 means no custom limit. |
PostfwdUserLimit |
site.db, Site table |
Custom messages per hour for each login of an exempt domain. 0 means no custom limit. |
Examples
# Rebuild the rules
/go/postfwd
# Look at the generated rules (RHEL family)
cat /etc/postfwd/postfwd.cf
# Look at the generated rules (Debian and Ubuntu)
cat /etc/postfwd.cf
# Apply the new rules (the service name can differ by system)
systemctl restart postfwd
Output
The command prints nothing. Check the rule file to see the result.
| Operating system | Rule file |
|---|---|
| AlmaLinux, Rocky, CentOS, Red Hat, Fedora | /etc/postfwd/postfwd.cf |
| Debian, Ubuntu | /etc/postfwd.cf |
The file is overwritten on every run, so edits you make to it by hand are lost.
Example rule file
With a server limit of 5000, an external limit of 500, a domain limit of 1000, a login limit of 100, and one exempt domain with its own limits, the file looks like this:
id=Server; client_address!=8.8.8.8; action=rate(sender/5000/86400/REJECT Sorry, Daily limit exceeded: maximum 5000 messages allowed for server per day)
id=External; client_address!=127.0.0.1; action=rate(sender/500/86400/REJECT Sorry, Daily limit exceeded: maximum 500 messages allowed for external IPs per day)
id=Domain1; sender_domain==shop.example.com; action=rate(sender/2000/86400/REJECT Sorry, Daily limit exceeded: maximum 2000 messages allowed for domain $$sender_domain per day)
id=SASL1; sasl_username=~/@shop\.example\.com$/; action=rate(sender/200/3600/REJECT Sorry, exceeded 200 messages in 60 minutes for $$sasl_username)
id=ExcludeDomain1; sender_domain==shop.example.com; action=ok
id=ExcludeSASL1; sasl_username=~/@shop\.example\.com$/; action=ok
id=Domain; sender_domain=~/.*/; action=rate(sender/1000/86400/REJECT Sorry, Daily limit exceeded: maximum 1000 messages allowed for domain $$sender_domain per day)
id=SASL; sasl_username=~/.*/; action=rate(sender/100/3600/REJECT Sorry, exceeded 100 messages in 60 minutes for $$sasl_username)
Log
Each run appends one line to /var/log/go/postfwd.log:
[Nov 21 12:00:00]# postfwd
See the full reference at /go/postfwd and the GoAdmio command index.
GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.
