Monday, June 23, 2014

Sendmail: Clear / Delete / Flush Mail Queue

You can use the mailq command sendmail -bp command to display a summary of the mail messages queued for future delivery. Type the following command:
# mailq
OR
# sendmail -bp
Sample outputs:
  /var/spool/mqueue (1 request)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
p61J75u5037681      893 Fri Jul  1 14:07 
      8BITMIME   (Deferred: Connection timed out with example.com.)
      
  Total requests: 1
You can cd to /var/spool/mqueue and delete all files if you want to get rid of all messages in the queue:
# cd /var/spool/mqueue/
# ls
# rm *


Thanks to: http://www.cyberciti.biz/faq/linux-unix-bsd-clear-sendmail-queue/