Exim’s loop detection counts Received: headers and refuses delivery once the count exceeds the configured maximum (default 30). That catches the obvious loops: A forwards to B, B forwards to A, message bounces between them adding Received headers each time. It does not catch slower loops where each iteration takes hours, or loops through an external system that strips the headers between hops. Detection for those needs different tooling.
What’s happening
A mail loop forms when two or more delivery rules forward to each other directly or via a chain. Common shapes on cPanel: a forwarder pointing at an address that forwards back; an autoresponder triggered by an autoresponder (see the list-loops KB); a Sieve filter that forwards then files locally, while the destination forwards everything back. Some loops stay subtle because each iteration goes through different mailbox configurations, so Exim doesn’t see a tight bounce — it sees one new message at a time.
How to verify
Look at the highest-volume senders over the last hour, especially internal-to-internal:
exim -bp | awk '{print $4}' | grep -v "^$" | sort | uniq -c | sort -rn | head
grep "<= " /var/log/exim_mainlog | awk '{print $4, $5}' | sort | uniq -c | sort -rn | head
A pair of addresses dominating both as sender and recipient is the signature of a slow loop. Then trace one specific message ID through:
exigrep <message-id> /var/log/exim_mainlog
You should see the message looping between the two addresses.
The fix
- Identify both ends of the loop. Use the volume-grouped log query above. The two heavy interacting addresses are the suspects. Look at their forwarder, alias, and autoresponder configurations.
- Suspend one side immediately. Disable the forwarder or autoresponder on one of the two addresses. The loop stops within minutes; remaining messages drain from the queue.
- Reconstruct the configuration error. Walk both addresses’ setup. Common findings: a forwarder set during a migration that wasn’t removed when the alias was redirected; an autoresponder on a shared mailbox that responds to internal mail; a Sieve rule with a forward action that the user thought also kept the original.
- Set up the correct configuration. If A genuinely needs to forward to B and B back to A is also intended (rare but possible — for example, a shared archive setup), one side must explicitly drop loop-tagged messages. Exim’s filter can detect its own X-Loop header you add on outbound.
- Add monitoring. A daily check that no pair of internal addresses dominates the inbound volume between them catches slow loops within a day instead of a month.
For environments where mail loops happen often enough to need automated detection, Stack Harbor wires the alerting and the configuration audit into managed cPanel operations.