How To Flush Sendmail Queue In Linux

by lifeLinux on May 16, 2011

Check pending mail

To check how many pending mail, type the following command

# mailq


This will give you example output like this:

 /var/spool/mqueue (2 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
p4BHPCuP002174      105 Thu May 12 00:25 mualaco
                 (host map: lookup (nixonbox.com): deferred)
                                         [email protected]
p4B8uNPZ023735     1000 Wed May 11 15:56 saigonlab
                 (host map: lookup (gmail.com.vn): deferred)
                                         [email protected]
                Total requests: 2

There are several techniques to delete sendmail queue

Manually removed pending mails

Type the following commands

# rm -rf /var/spool/mqueue
# rm -rf /var/spool/clientmqueue

Final, restart mail service with the following command

# /etc/init.d/sendmail restart

Output like this

Shutting down sm-client:                                   [  OK  ]
Shutting down sendmail:                                    [  OK  ]
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]

You can also use find command to remove “Deferred: Connection refused” queues

# find /var/spool/mqueue -type f -exec grep "Deferred: Connection refused" {} \; -exec rm -rf {} \;

Related Posts:

Previous post:

Next post: