Mail Servers

Useful Qmail Commands

useful qmail commands
Qmail Commands

Useful Qmail Commands

This post discussing some useful Qmail Commands. It will help to troubleshoot the email issues on a Qmail server. Plesk Control Panel supports two Mail Transfer Agents (MTA). They are Postfix and Qmail.

Check some important Qmail commands below:

1. To get the count of the messages in the queue:

/var/qmail/bin/qmail-qstat

Sample Output:

[root@server ~]# /var/qmail/bin/qmail-qstat 
messages in queue: 9
messages in queue but not yet preprocessed: 0
[root@server ~]#

2. To list the messages in the queue:

/var/qmail/bin/qmail-qread

Sample Output:

[root@server ~]# /var/qmail/bin/qmail-qread
26 Jun 2018 15:51:11 GMT #71978662 15982 <> 
remote test@grepitout.com
25 Jun 2018 11:58:36 GMT #71977906 31600 <> 
remote test2@grepitout.com
25 Jun 2018 14:30:53 GMT #71978461 9279 <> 
remote test3@grepitout.com
30 Jun 2018 10:56:26 GMT #71970942 4336 <> 
remote test4@grepitout.com
28 Jun 2018 10:21:22 GMT #71977085 23003 <> 
remote test5@grepitout.com
[root@server ~]#

3. To read the contents of an email

find /var/qmail/queue -name MAIL_ID | xargs cat | less

Replace MAIL_ID with the 8 digit ID in the output of /var/qmail/bin/qmail-qread command.

4. To remove all emails from the queue

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 {} \;

5. To remove specific emails from the mail queue

qmail-remove -r -p test.com

Replace test.com with the desired string. Also, please note if the qmail-remove command doesn’t exist on your server, you need to install it.

Sample Output:

[root@server ~]# qmail-remove -r -p test@grepitout.com
71978652: no
71977085: no
71977087: no
71970929: no
71978461: no
71977020: no
71978662: yes
moved mess/1/71978662 to yanked/71978662.mess
moved remote/1/71978662 to yanked/71978662.remote
moved info/1/71978662 to yanked/71978662.info
71970942: no
71977906: no
1 file(s) match
[root@server ~]#

6. Mailbox location (In Plesk)

/var/qmail/mailnames/

That’s it!

Also Read:

If you like this post and wish to receive more articles from us, please like our FB page: GrepItOut

Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at info@grepitout.com

1 Comment

Click here to post a comment

Topics