exiqgrep
Search Exim queue messages
TLDR
Match the sender address using a case-insensitive search
Match the sender address and display message IDs only
Match the [r]ecipient address
Remove all messages matching the sender address from the queue
Test for bounced messages
Display the [c]ount of bounced messages
SYNOPSIS
exiqgrep [options] [expression]
PARAMETERS
-c
Show count of matching queue IDs instead of listing them
-C config_dir
Use specified directory for Postfix main.cf
-f sender
Match envelope sender address (wildcard support)
-g qid
Match specific queue ID
-h header
Match value in specified message header
-i
Ignore case for string matches
-l domain
Match messages with local recipient in domain
-o origin
Match envelope originator address
-q queue
Match specific queue: incoming, active, deferred, hold, corrupt
-r recipient
Match recipient address (wildcard support)
-s size
Match messages smaller than size (e.g., 10M)
-S size
Match messages larger than size (e.g., 10M)
-v
Invert the selection (show non-matching)
-x
Exact match, no wildcards
-!
Negate the match criteria
DESCRIPTION
exiqgrep is a powerful utility for searching and filtering messages in Postfix mail queues. It enables system administrators to query queue contents based on attributes like sender, recipient, size, queue ID, or custom headers, outputting matching queue IDs for further action.
Postfix organizes mail in queues such as incoming, active, deferred, hold, and corrupt. While mailq displays all queued mail, exiqgrep provides fine-grained selection, supporting wildcards (* and ?), case-insensitive matching, size comparisons, and negation. This is crucial for troubleshooting: identifying stuck messages, spam sources, oversized mails consuming disk space, or mails to problematic domains.
Output queue IDs can pipe directly to postsuper for deletion (-d), requeuing (-r), or holding (-H). For instance, remove mail larger than 10MB: exiqgrep -S 10M | xargs postsuper -d. It supports multiple criteria combined with AND logic and a trailing expression for additional pattern matching.
Safe for use with running Postfix instances, as it reads queue files without modification. Ideal for automated scripts monitoring queue health.
CAVEATS
Wildcards limited to * and ? (no regex). Multiple criteria use AND logic. Requires read access to Postfix queues (/var/spool/postfix). Use cautiously with postsuper to avoid deleting legitimate mail.
EXAMPLES
exiqgrep -r user@example.com | xargs postsuper -d
Delete mail for recipient.
exiqgrep -S 50M -q deferred
List large deferred mails.
exiqgrep -f '@spam.com' -i | xargs postsuper -d ALL
Case-insensitive delete from spam domain.
HISTORY
Developed by Liviu Daia for Postfix around 2002-2003. Included in Postfix 2.1+. Evolved to support more queues and options with Postfix releases.


