To see mail queue, enter:
mailq
To flush or purge the postfix mail queue, just enter this command
postfix flush
If you want to retry all messages in the deferred queue:
postsuper -r ALL
But if you need to delete an individual email from the queue, you'll first need to see the queue. Traditionally you use mailq this time we'll use:
postqueue -p
And the output should show all messages in queue:
5642B4D8647* 1683500 Tue Jun 3 08:37:27 xxxxxx@xxxxxxx.com
rrrrrrrrr@hotmail.com
9359B4D82B1* 1635730 Tue Jun 3 08:36:53 xxxxxx@xxxxxxx.com
yyyyyyyy@hotmail.com
The first number is the message ID, if you only want to delete one of them, enter:
postsuper -d 5642B4D8647
That will only delete one email for the queue, that specific email you want to delete from it.
To remove all mail from the queue, enter:
# postsuper -d ALL
To remove all mails in the deferred queue, enter:
# postsuper -d ALL deferred
To delete all email in the queue from a specific email address
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } /username@example\.com/ { print $1 }' | tr -d '*!' | postsuper -d -
To delete all email in the queue from a specific subject
cd /var/spool/postfix/deferred
grep -r -i -l "This was the subject line" ./ | cut -d/ -f3 | postsuper -d -
If you need to purge all undelivered bounce-back mails from a users inbox then do the following:
cd /var/qmail/mailnames/*domain*/mailbox/cur/
find ./ -type f -name '*' -print0 | xargs -0 grep -l "MAILER-DAEMON@mail.webcorecloud.com" |xargs rm
Another way to achieve this is with the following command:
mailq | tail -n +2 | head -n -2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($7 == "MAILER-DAEMON") print $1 }' | tr -d '*!' | postsuper -d -
0 Comments
Please log in to leave a comment.