Remove messages from the mail queue – Exim

Exim is a mail transfer agent (MTA) used on many Linux operating systems, especially on web hosting servers. Even if web hosting control panels like cPanel, DirectAdmin, Plesk, VestCP offers the possibility to manage the mail queue from the GUI interface, sometimes it can be faster to manage it from the command line. We will list some useful commands. For more information on these, please consult the exim command line manual.

First, you will probably want to list the messages in the queue. Use:

exim -bp
root@www [~]# exim -bp

 6h  9.7K 1iduBA-0002W9-3a <News@domain.com>
          email@gmail.com

 4h   23K 1idwSE-0005Wp-81 <>
          clubdjpr@www.plothost.com

 4h  9.0K 1idwTc-0005cJ-QN <> *** frozen ***
          b2evo-return@domain.com

 3h  156K 1idxAf-0000O8-HW <n0238a2e840-a0d3d4d86ebc44ba-brian===domain.com@bounce.twitter.com>
          brian@domain.com

 2h  8.7K 1idxkx-0003AF-1I <> *** frozen ***
          b2evo-return@domain.com

66m   13K 1idypK-0008I8-6G <> *** frozen ***
          user123@live.com

To remove a message from the queue, use:

exim -Mrm <message-id>
root@www [~]# exim -Mrm 1idypK-0008I8-6G
Message 1idypK-0008I8-6G has been removed
root@www [~]#

To remove all the messages from the queue:

root@www [~]# exim -bpru | awk '{print $3}' | xargs exim -Mrm
Message 1idkGG-0004yI-T6 has been removed
Message 1idybs-0007CS-Jz has been removed
Message 1idxkx-0003AF-1I has been removed
Message 1idPGM-00029i-Qs has been removed
Message 1idPwR-0004v5-8L has been removed
Message 1idnzB-0007Iz-LG has been removed
Message 1idWRB-00029m-U9 has been removed
Message 1idjdw-0001hu-Hy has been removed
Message 1idElw-0001kf-Ps has been removed
Message 1idndS-0005Mk-EO has been removed
Message 1idOBS-0006IH-Tm has been removed
Message 1idPut-0004mI-68 has been removed
Message 1idgb5-000375-B1 has been removed
Message 1idxAf-0000O8-HW has been removed
Message 1ictBh-00072Q-5h has been removed

Notice that the previous command will delete all the messages regardless on the time they were added to the queue.

In WHM(Web Host Manager) you can easily manage the mail queue from Home->Email->Mail Queue Manager:

whm mail manager
WHM Mail Queue Manager

Reference:
exim command line manual

Leave a Reply