Skip to content

Diagnosing mail loop errors on cPanel

A cPanel mail loop quietly fills the queue and bounces messages with "mail forwarding loop." Here is how to trace the loop, identify the bad alias, and stop it.

A mail loop on a cPanel server is one of the quieter incidents. There is no outage, no front-page complaint, just a steadily growing Exim queue and a thin stream of bounces with mail forwarding loop or too many "Received" headers — mail loop suspected. Left alone for a weekend, a loop will fill the disk, exhaust the per-recipient rate limits, and start tripping 421 Too many concurrent SMTP connections against the receiving side.

What’s happening

A loop is created when a domain or address forwards mail to a destination that, directly or transitively, forwards it back. Common shapes on cPanel: a domain-level forwarder pointing to an address on the same server which forwards back to the original; an MX record pointing offsite while the local cPanel account still treats the domain as local and tries to deliver locally; a .forward file or autoresponder triggering on every received message including its own delivery report. Exim catches most of these via the Received: header count, but only after the queue has already filled.

How to verify

Look at the queue and the frozen messages first:

exim -bp | tail -50
exim -bpc
exim -Mvh <message-id> | grep -i 'received:'

A message with more than ten Received: headers, all bouncing between two hostnames you recognise, is the loop. Then check the forwarders and the MX/local-domain mismatch:

grep -r '<looping-address>' /etc/valiases/
grep '<domain>' /etc/localdomains /etc/remotedomains
dig +short MX <domain>

If the domain is in /etc/localdomains but its MX record points elsewhere, cPanel will accept locally while the MX expects offsite delivery — classic split-horizon loop.

The fix

  1. Identify the loop endpoints from the Received: chain.
  2. Remove the offending forwarder in cPanel > Forwarders, or edit /etc/valiases/<domain> directly and run /scripts/updateuserdomains.
  3. If the loop is MX-vs-local-mode mismatch, set the domain’s mail routing correctly in WHM > Edit MX Entry: Remote Mail Exchanger if mail lives offsite, Local if it lives on this server. Confirm the domain appears in only one of /etc/localdomains or /etc/remotedomains.
  4. Clear the queue of looped messages:
    exim -bpr | awk '/looped-recipient@example.com/ {print $3}' | xargs exim -Mrm
  5. Add monitoring on exim -bpc so the next loop is caught while the queue is small.

If you’d rather have alerts wired up before the queue fills, that monitoring is part of our monitoring and support engagement.