viewing and editing mail queues. | ramblings of a sysadmin.

viewing and editing mail queues.

while i’m excited about getting mail to work on my linux box after such a long time, i think it’s appropriate to address some useful applications to view mail queues (and edit them whenever necessary).
first, let’s look at this in sendmail.
you can use one of the two commands below which essentially do the same thing:
# /usr/sbin/sendmail -bp
/var/spool/mqueue is empty
Total requests: 0

# mailq
/var/spool/mqueue is empty
Total requests: 0

if you have numerous messages in your queue and you want to empty them out, simply:
# cd /var/spool/mqueue
# rm

now, to do the same on qmail, you will need to get an application called qmHandle. once you install this, you can view the number of messages in the queue by typing:
# qmHandle -s
Messages in local queue: 0
Messages in remote queue: 47

if you want more detailed information, including messageid, from, to, and subject lines:
# qmHandle -l
you can delete items with problematic subject lines as such:
# qmHandle -S’failure notice’
# qmHandle -Sailure
will work just as well (and will delete all emails that include the text string “ailure” in the subject).
you can also view the subject/from/to of emails in the queue by typing:
fgrep Subject /var/qmail/queue/mess/*/*
fgrep From /var/qmail/queue/mess/*/*
this command is far more useful — it will search each email for any text in the email, whether body, subject, recipient, or sender.
any offensive emails in the queue? you now know where to go.
# fgrep Testing /var/qmail/queue/mess/*/*
# rm /var/qmail/queue/mess/12/28952688

finally, you can attempt to send all emails in the queue by using the command below:
# qmHandle -a
if the emails cannot be sent at any time for whatever reason, they will remain in the queue.

Leave a Reply

Post Navigation