Queue Inspection
These commands let you see what's sitting in the Exim mail queue — waiting to be delivered, frozen, or deferred.
Show all messages in the queue with details:
exim -bpOutput includes message ID, age, size, sender, and recipient for each queued message. Frozen messages are marked with *** or flagged as frozen.
Count messages in the queue:
exim -bpcReturns a single integer — the total number of messages currently in the queue. Useful for monitoring scripts and alerts.
Show queue summary grouped by domain:
exim -bp | exiqsummexiqsumm is a Perl script included with Exim that summarises queue contents by recipient domain — useful when diagnosing a delivery problem to a specific destination.
List message IDs only (pipe-friendly):
exim -bp | grep '^ *[0-9]' | awk '{print $3}'Extracts just the message IDs for use in loops and bulk operations.
Show details for a specific message:
exim -Mvh <message-id>Displays the message headers. Replace -Mvh with -Mvb to see the message body, or -Mvi for the message's internal Exim metadata file.
Flushing and Retrying the Queue
When you've fixed a delivery problem (DNS issue, greylisting, remote server was down), you'll want to retry queued messages immediately rather than waiting for the next scheduled queue run.
Flush the queue — attempt delivery of all queued messages now:
exim -qffThe -qff flag means "queue run, force frozen". It retries all messages including frozen ones. Use -q alone to retry non-frozen messages only, or -qf to force a queue run without delivering frozen messages.
Queue run flags explained:
| Flag | Behaviour |
|---|---|
exim -q | Standard queue run — retries deferred messages, skips frozen |
exim -qf | Force queue run — delivers even if retry timer hasn't expired |
exim -qff | Force queue run including frozen messages |
exim -qqff | Two-pass queue run forcing frozen — more thorough on large queues |
Retry a single specific message:
exim -M <message-id>Removing Messages from the Queue
Sometimes you need to remove messages from the queue — spam that got queued before filtering was applied, messages to a dead domain, or test messages you don't want delivered.
Remove a single message by ID:
exim -Mrm <message-id>Remove all frozen messages (bulk):
exiqgrep -z -i | xargs exim -Mrmexiqgrep -z lists frozen message IDs. -i outputs IDs only. The result is piped to exim -Mrm for bulk removal.
Remove all messages from a specific sender:
exiqgrep -i -f 'sender@example.com' | xargs exim -MrmRemove all messages to a specific recipient domain:
exiqgrep -i -r '@baddomain.com' | xargs exim -MrmRemove all messages in the queue (nuclear option — use with caution):
exim -bp | awk '/^ *[0-9]/ {print $3}' | xargs exim -MrmChecking Routing and Address Testing
Before sending mail to an address, or when debugging delivery failures, you can ask Exim how it would route a message without actually sending it.
Test how Exim would route an email address:
exim -bt user@example.comShows the router and transport that would handle delivery, the next-hop MX, and any rewriting rules that apply. Invaluable for debugging misrouted mail.
Test address with debug output:
exim -d -bt user@example.com 2>&1 | lessThe -d flag enables full debug output — shows every decision Exim makes while routing, including ACL checks, router matching, and transport selection.
Verify an address is syntactically valid:
exim -bv user@example.comCheck what MX records Exim would use:
exim -bt -v user@example.comTesting SMTP Delivery
You can feed raw SMTP commands to Exim for testing without needing to open a real SMTP connection. This is useful for testing ACLs, spam filters, and local delivery.
Send a test email from the command line:
echo "Test message body" | exim -v -f sender@example.com recipient@example.comThe -v flag shows verbose delivery output. Exim will attempt delivery immediately and show you the result.
Feed a full RFC 2822 message to Exim (SMTP batch mode):
exim -bS << EOF
EHLO testhost
MAIL FROM:<sender@example.com>
RCPT TO:<recipient@example.com>
DATA
From: sender@example.com
To: recipient@example.com
Subject: Test
This is a test message.
.
QUIT
EOFTest Exim's SMTP server directly with telnet or netcat:
telnet localhost 25Then type SMTP commands manually. Press Ctrl+] then type quit to exit telnet.
Viewing and Analysing Mail Logs
Exim logs are typically at /var/log/exim4/mainlog (Debian/Ubuntu) or /var/log/exim/mainlog (RHEL/CentOS). The log format is line-based with a timestamp and message ID on each line.
Follow the Exim main log in real time:
tail -f /var/log/exim4/mainlogShow all log entries for a specific message ID:
grep '1abc12-000001-AB' /var/log/exim4/mainlogFind all delivery failures (bounces) in the log:
grep 'rejected\|bounce\|failed\|SMTP error' /var/log/exim4/mainlog | tail -100Find all messages rejected by ACL (spam/policy rejections):
grep 'rejected after DATA\|rejected RCPT' /var/log/exim4/mainlog | tail -50Count deliveries per hour (quick volume check):
grep 'Completed' /var/log/exim4/mainlog | awk '{print $1, $2}' | cut -c1-13 | sort | uniq -cFind top sending IPs (useful after spam incident):
grep 'SMTP connection from' /var/log/exim4/mainlog | grep -oP '\[[\d.]+\]' | sort | uniq -c | sort -rn | head -20Search across gzipped rotated logs:
zgrep 'user@example.com' /var/log/exim4/mainlog.*.gzHandling Frozen Messages in Bulk
Frozen messages are ones Exim has given up retrying temporarily. They accumulate when a remote server is persistently down, or when messages are undeliverable. You need to either thaw (retry) or remove them.
Count frozen messages:
exiqgrep -z -cList frozen message IDs:
exiqgrep -z -iThaw (unfreeze) all frozen messages so Exim will retry them:
exiqgrep -z -i | xargs exim -MtRemove all frozen messages:
exiqgrep -z -i | xargs exim -MrmFreeze a specific message manually (stop delivery attempts):
exim -Mf <message-id>Thaw a specific frozen message:
exim -Mt <message-id>Checking Exim Version and Configuration
Check Exim version:
exim --versionOr:
exim -bVThis also shows compile-time options, which tells you what features are compiled in (TLS, DKIM, SPF support, etc.).
Show Exim configuration file location:
exim -bP config_fileVerify Exim configuration syntax (dry-run config check):
exim -C /etc/exim4/exim4.conf -bVIf the configuration has syntax errors, Exim will report them here without affecting the running daemon.
Show all Exim configuration options currently in use:
exim -bPCheck Exim's process status:
systemctl status exim4Or on older init systems:
service exim4 statusRestart Exim (Debian/Ubuntu):
systemctl restart exim4Reload Exim configuration without restart:
systemctl reload exim4Or send SIGHUP to the Exim daemon PID:
kill -HUP $(cat /var/run/exim4/exim.pid)Quick Reference Table
| Task | Command |
|---|---|
| Show queue | exim -bp |
| Count queue | exim -bpc |
| Flush queue (incl. frozen) | exim -qff |
| Remove single message | exim -Mrm <id> |
| Remove all frozen | exiqgrep -z -i | xargs exim -Mrm |
| Thaw all frozen | exiqgrep -z -i | xargs exim -Mt |
| Test routing for address | exim -bt user@domain.com |
| View message headers | exim -Mvh <id> |
| View message body | exim -Mvb <id> |
| Retry single message | exim -M <id> |
| Freeze single message | exim -Mf <id> |
| Check version | exim -bV |
| Check config syntax | exim -bV -C /path/to/exim.conf |
| Watch mail log | tail -f /var/log/exim4/mainlog |
| Count frozen messages | exiqgrep -z -c |
Need Help?
Melbits provides managed IT support for Melbourne businesses, including Linux server administration and email server management. If your Exim server is having delivery issues, accumulating frozen messages, or you suspect it's been used for spam relay, contact us for assistance. Call 1800 635 248 or get in touch online.