This post is a partial copy of this article.
—————————————————————————————————————
Message-IDs and spool files
The message-IDs that Exim uses to refer to messages in its queue are mixed-case alpha-numeric, and take the form of: XXXXXX-YYYYYY-ZZ. Most commands related to managing the queue and logging use these message-ids. There are three files for each message in the spool directory. If you’re dealing with these files by hand, instead of using the appropriate exim commands as detailed below, make sure you get them all and don’t leave Exim with remnants of messages in the queue.
Files in /var/spool/exim/msglog
contain logging information for each message and are named the same as the message-id. Files in /var/spool/exim/input
are named after the message-id, plus a suffix denoting whether it is the envelope header (-H) or message data (-D). These directories may contain further hashed subdirectories to deal with larger mail queues.
Basic information
Print a count of the messages in the queue:
# exim -bpc
Print a listing of the messages in the queue (time queued, size, message-id, sender, recipient):
# exim -bp
Print a summary of messages in the queue (count, volume, oldest, newest, domain, and totals):
# exim -bp | exiqsumm
Print what Exim is doing right now:
# exiwhat
Test how exim will route a given address:
# exim -bt alias@localdomain.com
Run a pretend SMTP transaction for a given IP:
# exim -bh 192.168.11.22
This will display Exim’s checks, ACLs, and filters as they are applied. The message will NOT actually be delivered.
Display all of Exim’s configuration settings:
# exim -bP
Searching the queue with exiqgrep
For messages from a specific sender:
# exiqgrep -f [luser]@domain
For messages for a specific recipient/domain:
# exiqgrep -r [luser]@domain
Print messages older than than 1 day:
# exiqgrep -o 86400 [...]
For messages less than an hour old:
# exiqgrep -y 3600 [...]
There are also a few flags that control the display of the output. Use -i
to print just the message-id. Use -c
to print a count of messages matching the condition.
Managing the queue
Remove a message from the queue:
# exim -Mrm <message-id>
Freeze a message:
# exim -Mf <message-id>
Thaw a message:
# exim -Mt <message-id>
Deliver a message, whether it’s frozen or not, whether the retry time has been reached or not:
# exim -M <message-id>
Deliver a message, but only if the retry time has been reached:
# exim -Mc <message-id>
Remove all frozen messages:
# exiqgrep -z -i | xargs exim -Mrm
Remove all messages older than five days (86400 * 5 = 432000 seconds):
# exiqgrep -o 432000 -i | xargs exim -Mrm
Freeze all queued mail from a given sender:
# exiqgrep -i -f luser@example.tld | xargs exim -Mf
View a message’s headers:
# exim -Mvh <message-id>
View a message’s body:
# exim -Mvb <message-id>
View a message’s logs:
# exim -Mvl <message-id>