ow can I permanently delete all e-mail messages in the Sendmail mail server (SMTP) queue using UNIX / Linux command prompt?
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
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 *
OR
Postfix Flush the Mail Command
Traditionally we used the “sendmail -q” command to flush the mail queue under Sendmail MTA. Under Postfix MTA, just enter the following command to flush the mail queue:# postfix flush
OR# postfix -f
## OR ##
# postqueue -f
The above command tell Postfix to process the queue now and flush all emails.
How to see emails in Postfix message queues
The postqueue command implements the Postfix user interface for queue management. To see mail queue type any one of the following command:# mailq
OR# postqueue -p
Sample outputs:
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- EC4D438AA57 429 Fri Jun 25 07:54:19 webmaster@itcertified.pro (connect to email-smtp.us-west-2.amazonaws.com[44.229.96.139]:587: Connection timed out) -- 0 Kbytes in 1 Request.
Note down Postfix Queue ID. For example, EC4D438AA57. Now, we can further review message contents, header, and body in your Postfix queue using Queue ID as follows:# postcat -vq Queue-ID
# postcat -vq EC4D438AA57
Deleting or removing all emails from Postfix queue
To remove all mail from the queue, enter:# postsuper -d A
ll
Summary of all commands you need to view and flush the Postfix mail queue:
Activity | Command |
---|---|
View or see queued mail | postqueue -p OR mailq |
Flush queued mail | postqueue -f OR postfix flush |
Purge queued mail | postsuper -d {ID} |
To purge all email from the queue | postsuper -d ALL |
Delete all deferred from Postfix queue | postsuper -d ALL deferred |
Recent Comments