exim, playing with mail queue in server

there are over thousand emails queue in our mail server, even though I have configured email frozen more than 10 days automatically delete/remove, but it seem like doesn’t work as expected.

here is the work around if you plan to do it manually.

start with listing email queue in the server, by using the command exim -bp, it will list all the email currently queue in the server. but my only concern is frozen email in the server, which I would like to manually clean it from the queue. let try something here,

exim -bp | grep frozen

18d 24K 1JhiI4-00096B-OW <> *** frozen ***
18d 2.3K 1JhiII-00097Y-8s <> *** frozen ***
16d 2.8K 1JhiKM-0009AL-9M <> *** frozen ***
15d 2.3K 1JhiLO-0009Bs-EF <> *** frozen ***
15d 2.5K 1JhiLS-0009Bx-O2 <> *** frozen ***
12d 2.7K 1JhiNm-0009S5-AQ <> *** frozen ***
10d 3.3K 1JhiPv-0009aN-Vu <> *** frozen ***
10d 24K 1JhiQ9-0009as-4R <> *** frozen ***

There are the emails currently queue in the server, and now you might want to check why did the email was queue in the server by exim -Mvl

2008-04-02 15:58:52 Received from <> H=(xxx.xxx.net) [202.76.234.132] P=esmtp S=2143 id=20080402075613.8287E22E8BB@xxx.xxx.net
2008-04-02 15:58:52 routing failed for rsvundet_2002@xxxx.com.my: User account not exist
*** Frozen (delivery error message)

If you want to remove all the email from queue more than 18 days, try this command;

exim -bp | grep 18d | awk ‘{ print $3 }’ | xargs exim -Mrm

Message 1JhiI4-00096B-OW has been removed
Message 1JhiII-00097Y-8s has been removed
Message 1JhiKM-0009AL-9M has been removed
Message 1JhiLO-0009Bs-EF has been removed
Message 1JhiLS-0009Bx-O2 has been removed
Message 1JhiNm-0009S5-AQ has been removed

some usefull queue commands:

-bp : Queue email in Server
-bpc : Count Queue email in Server
-M : Force delivery
-Mar : Add recipient
-Meb : Edit message body
-Mes : Edit sender
-Mf : Freeze message
-Mg : Give up (and bounce message)
-Mmad : Mark all recipients as delivered
-Mmd : Mark recipient as delivered
-Mrm : Remove message (no bounce)
-Mt : Thaw message
-Mvb : View message body
-Mvh : View message header
-Mvl : View message log

enjoy and happy cleaning queue email!

Links

Exim Cheat Sheet by bratthemad
Last update: 20080721