Solved

Clear qmail mail queue

Posted on 2007-04-03
4
4,489 Views
Last Modified: 2013-12-02
I have a dedicated server running qmail.
I need know how to clear the email queue.

Thanks.
0
Comment
Question by:steelseth12
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:nishin
ID: 18846281
You can also purge the queue by below commands:-
To start qmail
svc –u /service/qmail/
svc –u /service/smtpd/
To stop qmail
svc –d /service/qmail/
svc –d /service/smtpd/

Below is the handy info about qmail:=
-----------------------------------------------

Some important directories/ files are:
Directories:
/var/qmail/bin                        :      contains the qmail binaries
/var/qmail/service/qmail/log/main      :      contain the qmail log files

Files:
/var/qmail/service/qmail/log/main/current : this file contains latest/ current information about the queue

Some important commands related to qmail are:
(WARNING: not all commands are supposed to be run by users)

•qmail-qstat gives a human-readable breakdown of the number of messages at various spots in the mail queue.
•qmail-qread scans the outgoing queue of messages. For each message it prints various human-readable information, including the date the message entered the queue, the number of bytes in the message, the message sender, and all the recipients still under consideration.

A few words about the queue pileup:
The qmail server is very efficient in mail relaying and delivery. However, it is dependent on some underlying services. For example: DNS server and Network connectivity. If either of them is not upto the mark, then qmail server will not be able to relay mails, leading to a queue pileup. Hence check the following things:
1.      Verify with the networking team if the network connectivity is OK.
2.      Verify with the networking team if the DNS is working fine.
(We’ve had many instances where the server receives many mails for a domain which is not having its MX record defined properly or is not defined. Get this rectified by the networking team or the DNS team and the queue should come down quickly. The commands to find out the messages to/from a given domain are given below.)







Following steps may be used to manage the queue pileup:

1.      Check the number of messages in the queue
http://e2ksmtp01.test.com/mrtg/
qmail-qstat

2.      Get the number of mails relayed
grep -c accepted current ; grep -c new current
987      (Delivered mail)
577      (New mails, waiting to deliver)

3.      How to track the messages,  with the "TO Address" information
a> [root@e2ksmtp01 qmail]# grep 'karthik.s@test.com' *
@4000000040a534881db6e53c.s:@4000000040a532700521703c starting delivery 13653102: msg 1093445 to remote karthik.s@test.com
current:@4000000040a539ee2fac086c starting delivery 13658719: msg 1096679 to remote karthik.s@test.com
      b>      grep 13653102 *
@4000000040a534881db6e53c.s:@4000000040a532700521703c starting delivery 13653102: msg 1093445 to remote karthik.s@test.com
@4000000040a534881db6e53c.s:@4000000040a5327014d6a5ec delivery 13653102: success: 3.159.213.46_accepted_message./Remote_host_said:_250_2.6.0__<20040514205606.11097.qmail@e2ksmtp01.test.com>_Queued_mail_for_delivery/
      c>  grep 13658719 *
current:@4000000040a539ee2fac086c starting delivery 13658719: msg 1096679 to remote karthik.s@test.com
current:@4000000040a539ef0e6280b4 delivery 13658719: success: 3.159.213.26_accepted_message./Remote_host_said:_250_2.6.0_<CINMLEF01ka09NmXyYm00000f13@cinmlef01.e2k.ad.test.com>_Queued_mail_for_delivery/




      




4.      To see the messages in the queue currently
tail –f current
While tailing this file, you will get some idea about the mails. Try to figure the domain to which maximum number of messages are destined. After getting this information, check if the MX record of that domain is configured properly. If not, get this into the nmotice of DNS team/Shift manager to get this corrected.

5.      To get the messages in the queue related to ps.test.com
root@e2ksmtp01 main]# qmail-qread |grep ps.test.com |more

6.      To get the number of messages in the queue related to ps.test.com
root@e2ksmtp01 main]# qmail-qread | grep ps.test.com | wc -l
        
8.  To see mails for only ps.test.com: Run the below command
root@e2ksmtp01 main]# qmail-qread | grep -A1 ps.test.com | more
      3 Jun 2005 14:51:27 GMT  #1094294  5499  <atul.aggarwal@ps.test.com>  remote      john.cederman@ps.test.com
      2 Jun 2005 17:09:55 GMT  #1094202  2828  <> remote      tatiana.rosato@ps.test.com
      3 Jun 2005 12:22:45 GMT  #1094340  3225  <abdelillah.misbah@ps.test.com> remote christopher.spriegel@ps.test.com
      3 Jun 2005 06:00:14 GMT  #1095237  3524  <> remote      sameer.chitnis@ps.test.com

7.      To get the number of un-delivered messages received on 30th or 2nd June March queue
root@e2ksmtp01 main]#qmail-qread |grep –c "30 Mar"
root@e2ksmtp01 main]#qmail-qread |grep –c "2 Jun"

8.      List the current messages in queue.
             a> root@e2ksmtp01:ls -lt
      total 2467300
-rw-r--r--    1 qmaill   nofiles     59487 Jun  3 10:54  [00mcurrent
-rwxr--r--    1 qmaill   nofiles    998008 Jun  3 10:54  [01;32m@4000000042a06f2c101587e4.s
-rwxr--r--    1 qmaill   nofiles    998079 Jun  3 10:51  [01;32m@4000000042a06e712382242c.s
-rwxr--r--    1 qmaill   nofiles    998087 Jun  3 10:48  [01;32m@4000000042a06dc708569714.s
-rwxr--r--    1 qmaill   nofiles    998158 Jun  3 10:45  [01;32m@4000000042a06d220e3de984.s
-rwxr--r--    1 qmaill   nofiles    998033 Jun  3 10:43  [01;32m@4000000042a06c8e28431b24.s

b> To read log file "@4000000042a06f2c101587e4.s" Run the below command.
      From here you can find if the mails are not getting relayed for a particular domain.
      Go to the folder /var/qmail/service/qmail/log/main
     [root@e2ksmtp01 main]# cat @4000000042a06f2c101587e4.s |more
      @4000000042a06e712847b2ec status: local 0/120 remote 78/120
@4000000042a06e712849f124 starting delivery 2111462: msg 1096015 to remote tsing let@wmcdirect.com
      @4000000042a06e71284a4714 status: local 0/120 remote 79/120
      @4000000042a06e7128c1ebfc delivery 2111458: failure: Sorry,_I_couldn't_find_any_host_named_homelender.com._(#5.1.2)/
      @4000000042a06e7128ca9e8c status: local 0/120 remote 78/120
      @4000000042a06e7129c69674 bounce msg 1093870 qp 18749
      @4000000042a06e7129c9c6dc end msg 1093870
      @4000000042a06e7129d51d34 new msg 1096106
      @4000000042a06e7129d7ccb4 info msg 1096106: bytes 2588 from <> qp 18749 uid 197
      @4000000042a06e712a60983c starting delivery 2111463: msg 1096106 to remote webmaster@wmcdirect.com
5> Lets say if there are mails from a specific user which is not getting relayed or if someone is trying to relay: Run the
      below command to locate that message and open that message.
           a>  root@e2ksmtp01 main]# locate -u
b> root@e2ksmtp01 main]# locate -u 1094294
            /var/qmail/queue/mess/0/1094294
            /var/qmail/queue/info/0/1094294
            /var/qmail/queue/remote/0/1094294
      c> root@e2ksmtp01 main]# vi /var/qmail/queue/mess/0/1094294
 [?1048h [?1047h [?1h = [1;24r [?25h [?25h [27m [m [H [2J [?25l [24;1H"/var/qmail/queue/mess/0/1095375" 72L, 3217C [1;1HReceived: (qmail 23499 invoked from network); 3 Jun 2005 12:22:52 -0000
      Received: from unknown (HELO scgpweb07.nam.corp.test.com) (3.184.217.71)
       by 0 with SMTP; 3 Jun 2005 12:22:52 -0000
Received: from mail pickup service by scgpweb07.nam.corp.test.com with Microsoft S  [5;1HMTPSVC; [6;10HFri, 3 Jun 2005 08:22:52 -0400


      From: <abdelillah.misbah@ps.test.com>
      To: <andre.wizner@ps.test.com>
Subject: GIS-CMC-Emergency < 2 Hrs -- Shutdown of frbora58, frbora59 and frbora6  [10;1H0 -- FRANCE / BELFORT -- Open --
      Date: Fri, 3 Jun 2005 08:22:52 -0400
      MIME-Version: 1.0
      Content-Type: multipart/alternative; [14;9Hboundary="----=_NextPart_000_3737_01C56815.6F5EC190"
      X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
      Message-ID: <SCGPWEB07JX7rVGSLsN0000425b@scgpweb07.nam.corp.test.com>
      X-OriginalArrivalTime: 03 Jun 2005 12:22:52.0405 (UTC) FILETIME=[F68F8250:01C568  [18;1H36]

      This is a multi-part message in MIME format.

      ------=_NextPart_000_3737_01C56815.6F5EC190
      Content-Type: text/plain; [1;1H [?25h


To do a nslookup type below command.
======================================
root@e2ksmtp01 main]# dig mx ps.test.com
mx ps.test.com
[root@e2ksmtp01 main]# telnet nyschx06psge.ps.test.com 25
0
 
LVL 20

Author Comment

by:steelseth12
ID: 18850578
hello nishin
thanks for the reply dont know if this is of any relevance but the server is running on freeBSD and the directory structure s different , also i dont have the qmail-qstat, qmail-qread commands available.
0
 
LVL 4

Accepted Solution

by:
nishin earned 500 total points
ID: 18858485
Sorry, i did realise its in FREEBSD, Ok below is the few commands

-Start qmail
# /usr/local/etc/rc.d/qmail.sh start

-Check qmail and tcpserver are running
# ps -ax | grep tcpserver
# ps -ax | grep qmail

You can refer the below links to:
---------------------------------------
http://logicsquad.net/freebsd/qmail-how-to.html
http://freebsd.qmailrocks.org/
http://www.bsdguides.org/guides/freebsd/mailserver/qmail+vpopmail+qmailadmin.php
0
 
LVL 20

Author Comment

by:steelseth12
ID: 18859499
Thanks for all your help
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

New-MailboxSearch Powershell Command and step by step approach to Search and Extract Emails form Exchange 2013 Journaling server.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now