You're probably here because the Mail Queue Manager is taking forever to load in WHM and you're wondering how you can flush the pending emails via SSH/ Terminal using some command. Right? You've come to the right place.
We've been there so we're leaving a quick help for you. Below is a quick way to flush the mail queue via command for WHM / EXIM based servers only.
Login into your server via root and run the following command :
exiqgrep -o 360 -i | xargs exim -Mrm
This will remove mails older than 6 mins (360 seconds). adjust your time accordingly.
Its wise to spare the emails shot in last few minutes to avoid mistakenly deleting the most recent emails which should be delivered while you were running the commands.
You can run the following command to pull the number of emails in queue (before or after running the command)
exim -bpc
You can also list the messages in the queue, however, this will take long if you've a big count in queue:
exim -bop
Summary of messages in the queue (count, volume, oldest, newest, domain, and totals):
exim -bp | exiqsumm
Display what Exim is doing right now:
exiwhat
Display all Exim configuration settings:
exim -bP