Postfix anvil and smtpd_client_rate_limit, Explained

A catch-all email address accepts every message sent to a domain, including the ones aimed at addresses that were never provisioned. That convenience is also an attack surface: spammers and scrapers learn one address pattern and generate thousands more, and the catch-all rule happily takes them all. Postfix administrators who run catch-all domains have a specific tool for this problem, and it sits earlier in the SMTP conversation than most people realize. The combination of anvil and smtpd_client_rate_limit throttles unknown-recipient floods before the catch-all rule ever sees them, which is the difference between a mailbox that fills with junk and one that stays clean.

Where the catch-all rule sits in the SMTP conversation

A standard mail server replies with 550 no such user when no mailbox matches the recipient address. That rejection happens during RCPT TO, before the message body is transferred and before any mailbox is written. A catch-all changes the outcome of that check: instead of rejecting, the server accepts the unknown recipient and routes the message to a designated catch-all mailbox. The order of operations matters here. Postfix evaluates recipient restrictions, including the catch-all lookup, and only after acceptance does it queue the message for delivery, run content filters, and write to storage.

This sequencing is why rate limiting placed after recipient acceptance is nearly useless against catch-all abuse. By the time the catch-all rule has said yes, the message has already consumed queue space, filter CPU, and eventually disk. A per-mailbox quota or a content filter that runs post-queue is cleaning up after the damage. The abuse has to be stopped at the point of connection or the point of command, before the recipient check resolves to an acceptance.

Postfix gives you two mechanisms that operate at that earlier layer. The anvil service tracks client connection and request rates in memory and enforces configured limits. The smtpd_client_rate_limit parameter tells smtpd to consult anvil and reject or defer clients that exceed a threshold of SMTP commands or messages per unit time. Both act on the connecting client, not on the recipient address, so they never distinguish between a legitimate named mailbox and an invented one. That is precisely the property you want when the recipient is unknown by definition.

Why recipient-level filtering misses the flood

Recipient-level defenses assume you can enumerate the bad addresses. With a catch-all domain, the bad addresses are unbounded and unpredictable, so a blocklist of rejected recipients will always lag behind the next generated pattern. Rate limiting inverts the model: it does not care which addresses are being tried, only how fast the client is trying them. A scraper that fires 200 RCPT TO commands in a minute stands out regardless of whether the addresses look plausible. A legitimate sender delivering one message to one named mailbox does not.

There is a second reason recipient-level filtering struggles. Catch-all domains are used for unlimited unpredictable addresses in automation and sign-ups, so the domain owner often cannot tell in advance which addresses are real. If you start rejecting recipients you do not recognize, you break the automation that motivated the catch-all in the first place. Rate limits avoid that trade-off because they target behavior, not identity.

Configuring anvil and smtpd_client_rate_limit for catch-all domains

Anvil is a Postfix service that maintains a per-client state table and answers rate queries from smtpd. It is enabled by default in a standard Postfix install, but the limits are permissive until you set them. The relevant parameters live in main.cf: smtpd_client_rate_limit sets the maximum number of SMTP commands or message deliveries per client per time unit, and anvil_rate_time_unit sets the window, defaulting to 60 seconds. A typical starting point for a catch-all domain is smtpd_client_rate_limit = 30 with the default 60-second unit, which allows a normal sender to complete a transaction comfortably while cutting off a client that tries to probe dozens of addresses in a burst.

The limit counts messages, not just commands, so a client sending a single legitimate message to a named mailbox is unaffected even if the message is large. What trips the limit is volume of transactions or commands from one client within the window. When a client exceeds the threshold, smtpd responds with a 450 or 421 temporary failure depending on configuration, and the client is expected to back off. Persistent offenders can be escalated to a permanent rejection with smtpd_client_event_limit_exceptions and related controls, but for catch-all abuse a temporary deferral is usually enough to make the flood uneconomical.

A working catch-all setup requires DNS pointing at the right host and a server accepting unknown recipients, and the rate limit is the third leg of that stool. If MX records route inbound mail to the wrong host, or if a downstream relay accepts the unknown recipient before your Postfix instance sees it, the rate limit never applies. Verify that the MX target is the Postfix host you configured, and verify that no intermediate system is doing recipient validation on your behalf.

Cloudflare, cPanel and the wildcard mailbox layer

Cloudflare Email Routing can forward mail for a domain, and its catch-all rule is configured in the Cloudflare dashboard rather than in Postfix. If Cloudflare forwards unknown recipients to your Postfix host, the connection arrives from Cloudflare’s infrastructure, not from the original sender, so anvil sees a small set of source IPs and rate limits based on those. That can be useful if you trust Cloudflare’s own filtering, but it also means your Postfix rate limit is measuring the wrong client. For domains where you need Postfix-level throttling of unknown-recipient floods, route MX records directly to your mail server and let Postfix handle the catch-all with its own rules.

cPanel exposes a catch-all setting per domain in the Email Deliverability or Default Address interface, and it maps to a wildcard mailbox or a forwarder on the underlying Exim or Dovecot stack. catch-all email examples has more details on this topic. cPanel’s UI does not surface anvil or smtpd_client_rate_limit, so on a cPanel host you configure the limits in the Exim configuration or in the Postfix main.cf if Postfix is the MTA. The principle is the same: the rate limit must be enforced by the MTA that performs the recipient acceptance, and it must run before the catch-all default address resolves.

What rate limits do and do not protect

Rate limits protect storage and filter CPU by cutting off the flood at the connection layer. They do not protect against a slow, patient sender that stays under the threshold while still delivering junk to the catch-all mailbox. A client sending one message every 90 seconds to invented addresses will never trip a 30-per-minute limit. For that pattern you need content inspection, DNSBL checks, or a policy that quarantines catch-all deliveries after a volume threshold. The rate limit is a blunt instrument, and blunt is the point: it stops the high-volume floods that account for most catch-all abuse.

Rate limits also do not distinguish a spam flood from a legitimate bulk sender that happens to target your domain. If a partner sends a newsletter to 50 addresses on your domain in one connection, a low limit will defer it. Size the limit against your legitimate traffic profile, and use anvil’s per-client exception list for known bulk senders rather than raising the global limit for everyone.

The interaction with catch-all is the important part. Because the limit is enforced before the recipient check, a flood of unknown-recipient probes is throttled without any effect on named mailboxes. A legitimate user checking IMAP or POP3 for a named address is not sending mail to the catch-all and does not touch the limit. The catch-all mailbox itself is the only thing that would have absorbed the flood, and the flood never reaches it.

Rate limiting versus aliases and forwarding

Catch-all differs from alias, forwarding and disposable addresses, and the difference affects how rate limits apply. An alias maps a specific address to a destination and is resolved during recipient lookup; a forwarder does the same with a different delivery target; a disposable address is usually a real mailbox with a short lifespan. All three are known recipients, so the catch-all rule is not involved. Rate limiting still applies to the client, but the protection you get from rejecting unknown recipients is not in play because the recipient is known. The catch-all mailbox is the only path where acceptance depends on a fallback rule, and that is where the rate limit earns its keep.

SPF, DKIM and DMARC govern outbound mail only, so they do nothing about inbound floods to a catch-all. A domain can have perfect authentication and still be flooded with unknown-recipient probes. Treat authentication and rate limiting as separate layers: authentication proves who sent a message, rate limiting controls how fast a client can send. The catch-all abuse problem is a rate problem, not an authentication problem.

Monitoring and tuning the limits over time

Anvil exposes its state through the anvil service logs and through Postfix’s smtpd logs. Watch for repeated 450 or 421 responses to the same client and for spikes in the number of RCPT TO commands per connection. A healthy catch-all domain will show a steady background of unknown-recipient probes, most of which are single-message attempts that never trip the limit. What you are looking for is clustering: many probes from one client within the window, or a rising rate of deferrals that suggests the limit is too tight for legitimate traffic.

Tuning is iterative. Start with a limit that comfortably accommodates your heaviest legitimate sender, then lower it until deferrals appear only for clients you do not recognize. Keep anvil_rate_time_unit at 60 seconds unless you have a specific reason to change it; shorter windows make the limit more sensitive to bursts, longer windows smooth out legitimate spikes but let sustained floods through. Document the values you choose and the traffic profile that justified them, because the next administrator will need that context.

AllMail.one publishes a guide to catch-all email that covers the DNS and server-side configuration in more detail, including how the catch-all rule interacts with recipient validation. The rate-limit layer is the part most guides skip, and it is the part that decides whether a catch-all domain stays useful or becomes a spam sink.

Set anvil limits before you enable the catch-all, not after. The order of enforcement is what makes the difference: limits at the connection layer throttle unknown-recipient floods before the catch-all rule accepts them, so storage and filter CPU never see the abuse. Named mailboxes, IMAP and POP3 clients, and legitimate automation keep working because the limit measures client behavior, not recipient identity. If you run a catch-all domain, the configuration work is small and the payoff is a mailbox that holds what you intended rather than everything a scraper could invent.

Mettiamoci in contatto

Se desideri ricevere una consulenza gratuita e senza alcun impegno, compila il modulo sottostante e ci metteremo in contatto con te.