====== Exim4 - Managing the queue ======
The main exim binary (/usr/sbin/exim) is used with various flags to make things happen to messages in the queue. Most of these require one or more message-IDs to be specified in the command line, which is where **exiqgrep -i** comes in handy.
Start a queue run:
exim -q -v
Start a queue run for just local deliveries:
exim -ql -v
Remove a message from the queue:
exim -Mrm [ ... ]
Delete all queued messages containing a certain string in the body:
grep -lr 'a certain string' /var/spool/exim/input/ | \
sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g' | xargs exim -Mrm
**NOTE**: The above only delves into **/var/spool/exim** in order to grep for queue files with the given string, and that's just because **exiqgrep** doesn't have a feature to grep the actual bodies of messages. If you are deleting these files directly, YOU ARE DOING IT WRONG! Use the appropriate exim command to properly deal with the queue.
If you have to feed many, many message-ids (such as the output of an **exiqgrep -i** command that returns a lot of matches) to an exim command, you may exhaust the limit of your shell's command line arguments. In that case, pipe the listing of message-ids into xargs to run only a limited number of them at once. For example, to remove thousands of messages sent from joe@example.com:
exiqgrep -i -f '' | xargs exim -Mrm
Freeze a message:
exim -Mf [ ... ]
Thaw a message:
exim -Mt [ ... ]
Deliver a message, whether it's frozen or not, whether the retry time has been reached or not:
exim -M [ ... ]
Deliver a message, but only if the retry time has been reached:
exim -Mc [ ... ]
Force a message to fail and bounce as "cancelled by administrator":
exim -Mg [ ... ]
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
View a message's body:
exim -Mvb
View a message's logs:
exim -Mvl
Add a recipient to a message:
exim -Mar [ ... ]
Edit the sender of a message:
exim -Mes
Remove bounce messages already in the queue:
exipick -f '^$' -i | xargs exim -Mrm
or, equivalently:
exipick '$sender_address eq ""' -i | xargs exim -Mrm