Install and use qmqtool

 

Install and use qmqtool

 

Qmqtool – a qmail queue manipulation program geared towards the viewing and safe modification of the contents in a qmail queue

Qmqtool is a utility designed for viewing and safely modifying the contents of a qmail queue. It is extremely feature rich, with features including finding abusers, sorting messages by sender/sender’s IP, showing stats, requeueing messages, queue consistency check, queue backup/restore, and others.

Configure it

cd /downloads/
tar zxvfp /downloads/qmqtool-1.14.tgz
cd /downloads/qmqtool-1.14/
./configure –perl=/usr/bin/perl –qmaildir=/var/qmail

You should have such result

found perl: /usr/bin/perl
found qmail directory: /var/qmail
qmqtool will be installed in: /usr/local/script
documentation will be installed in /usr/local/man

if any of these values need changing, try ./configure –help

Making sure this package is intact..
src/qmqtool syntax OK
…done.
Writing Makefile…

now type ‘make’ and then ‘make install’

Compile it

make
make install

You should have such result

mkdir -p /usr/local/script
cp qmqtool /usr/local/script
chown 0 /usr/local/script/qmqtool
chmod 755 /usr/local/script/qmqtool
mkdir -p /usr/local/man/man8/
cp qmqtool.8 /usr/local/man/man8/
chown 0 /usr/local/man/man8/qmqtool.8
chmod 744 /usr/local/man/man8/qmqtool.8

 

ln -s /usr/local/script/qmqtool /usr/local/bin/qmqtool

Use it

        qmqtool version 1.14
        syntax: qmqtool [-l] [-L] [-R] [-S [-nN]] [-T] [-s] [-Q] [-c] [-r] [-i [-nN]] [-V]
                        [-E(A|R|L)] [-U(A|R|L)] [-vN [-w]] [-e(N|[-f 'STRING'][-oN])] [-u(N|[-f 'STRING'][-oN])]
                        [-d(N|[-f 'STRING'][-oN])] [-f 'STRING'] [-oN] [-B(b|r)] [-x(N|[-f 'STRING'][-oN])]

        -l              list messages in all parts of the queue
        -L              list messages with local recipients
        -R              list messages with remote recipients
        -T              list messages not completely processed
        -s              show statistical information
        -Q              be as quiet as possible (useful for snmp, cron, and such)
        -V              be more verbose
        -B
          b             Backup queue into /var/qmail/queue.backup/
          r             Restore backup from /var/qmail/queue.backup/
        -c              check queue consitancy
        -r              repair queue (by deleting fragments) found by checking queue consistancy
        -i              show how many messages are queued per ip address
           -nN          pay attention to the Nth last smtp-hop
        -S              show how many bytes are queued per ip address
        -e              expire message
                        may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
        -u              unexpire message
                        may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
        -d              delete message
                        may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N
        -E              expire messages in [A]ll, [R]emote, or [L]ocal queues
        -U              unexpire messages in [A]ll, [R]emote, or [L]ocal queues
        -v
          N             view first 100 lines of message number N
          N -w          view whole message N
        -f 'STRING'     display comma separated list of message number(s) containing STRING.
                        prints 0 if no matches are found.
        -o N            display comma separated list of message number(s) older than N hours.
                        prints 0 if no matches are found.
        -x N            prints extended information on message N.  format identical to -l.
                        may specify N (multiples may be comma separated), or -f 'STRING' and/or -o N

Usage samples :

List all messages in the queue having the subject “XXX” (case insensitive)

qmqtool -f ‘/^subject: xxx/i’

Delete all messages in the queue having the subject “XXX” (case insensitive)

qmqtool -d -f ‘/^subject: xxx/i’
qmailctl restart

Who are the top senders for the remote queue

qmqtool -R | grep “From: ” | sort | uniq -c | sort -rn | head -20

Who are the top recipients of the remote queue

qmqtool -R | grep “To: ” | sort | uniq -c | sort -rn | head -20
qmqtool -R | grep “Envelope Recipient: ” | sort | uniq -c | sort -rn | head -20

What are the top subjects of the remote queue

qmqtool -R | grep “Subject: ” | sort | uniq -c | sort -rn | head -20

What domains are being sent the most mail from the server

qmqtool -R | grep “To: ” | cut -d @ -f2 | tr -d ‘>’ | sort | uniq -c | sort -rn | head -20
qmqtool -R | grep “Envelope Recipient: ” | cut -d @ -f2 | awk ‘{print $1}’ | tr -d ‘>’ | sort | uniq -c | sort -rn | head -20

Who are the top receivers for the local queue

qmqtool -L | grep “To: ” | sort | uniq -c | sort -rn | head -20
qmqtool -L | grep “Envelope Recipient: ” | sort | uniq -c | sort -rn | head -20

What domains are have the most mail in the local queue

qmqtool -L | grep “To: ” | cut -d @ -f2 | tr -d ‘>’ | sort | uniq -c | sort -rn | head -20
qmqtool -L | grep “Envelope Recipient: ” | cut -d @ -f2 | awk ‘{print $1}’

Who most of my remotely queued messages are destined for ?

qmqtool -R | awk ‘/Recipient:/ { print $3 }’ | sort | uniq -c | sort -n

How can I expire messages with a subject of “Failure Notice” that are have been queued for 18+ hours ?

qmqtool -V -e -o 18 -f ‘^Subject: Failure Notice’
Published in: on August 12, 2012 at 1:56 am  Comments Off on Install and use qmqtool  

Qmail Queue View

You can view all messages in the email queue.
To Display all Messages in the Email Queue

    Log in to your server using SSH.
    Type su -.
    Enter the password you used to log in to your server.
    At the command prompt, type:
    /var/qmail/bin/qmail-qstat
    To list multiple messages in the queue, type:
    /var/qmail/bin/qmail-qread

There is a built-in utility to control qmail called qmailctl. LifeWithqmail will put the file in /usr/bin/qmailctl.

‘qmailctl help’ will give you the general help output displaying the available commands. The following pertain to your question:

/usr/bin/qmailctl queue

This will show you the status of your queue, if messages are queued, run:

/usr/bin/qmailctl doqueue

This will deliver the queued messages for ‘immediate’ delivery

If you are curious on the messages being sent as you send them, locate the path of your log files and run a tail -f on the qmail-smtpd/current file. Below is an example:

/usr/bin/tail -f /var/log/qmail/qmail-smtpd/current

The -f flag will continue to monitor the file mentioned, displaying new data as it is being written to the file.

424Boyz

Published in: on November 3, 2011 at 7:03 pm  Comments Off on Qmail Queue View  

How to delete qmail queue ?

How to delete qmail queue ?

How to delete queue mail list from qmail queue while you have a bunch of queue mail stuck in qmail queue ?

Try the following syntax :

qmailctl stop
find /var/qmail/queue/mess -type f -exec rm {} \;
find /var/qmail/queue/info -type f -exec rm {} \;
find /var/qmail/queue/local -type f -exec rm {} \;
find /var/qmail/queue/intd -type f -exec rm {} \;
find /var/qmail/queue/todo -type f -exec rm {} \;
find /var/qmail/queue/remote -type f -exec rm {} \;
qmailctl start

But, I recommend to run this script not at busy time. I mean if you currently have busy traffic on qmail, otherwise your qmail won’t start properly and you must reboot your machine.

In other way to automatically remote qmail queue, is to set how long these qmail queues will stay, You can edit the /var/qmail/control/queuelifetime file this is the file to control how long a message stays in a queue. Just put a number (to represent seconds)in this file.By default 86400 sec Will keep the mail for 1 day and expire after that. Here you can change this value to 1 and restart your qmail server it should clear your qmail queue.

You can see on qmail log status at /var/log/qmail/qmail-send/current or /var/log/qmail/current.

Published in: on November 1, 2011 at 6:19 pm  Comments Off on How to delete qmail queue ?