[SOLVED] Selectively delete many mails from queue

wwweiss

Well-Known Member
Apr 28, 2018
31
6
48
63
Inside the Web-Admin it is very easy to look to the queues. Very often I see a lot of mails that should be deleted (maybe a customer makes something wrong which causes a few thousand mails hanging in the queue). What I would like to do is to delete all mails of a filtered view, maybe a Button "deleted all" which referes to the filter result or the option to mark many mails inside a list (typical select options with shift or ctrl) and then delete the marked mails - same as deleting a single mail.
Is this function already available and a do not see it or is this something for the wishlist?
Is there any posibility to do that via ssh?
 
You can delete _all_ messages in the queue (in the summary tab)
a multiselect in the deferred queue listing is not available - please create an enhancement request over at our bugzilla: https://bugzilla.proxmox.com
with a rationale, why you would want this

Is there any posibility to do that via ssh?
yes - the `mailq` command lists all mails in the queue - with `awk` you can print the message ids matching a particular sender and use `postsuper -d` to delete all such mails - see the manpage of postsuper (`man postsuper`) for an example.

as an alternative you could also use `postqueue` json output and jq to filter mails for deletion - e.g.:
Code:
 postqueue -j | jq 'select(.sender=="spammer@domain.com")|.queue_id'|sed -r 's/^\"(.*)\"$/\1/' | postsuper -d -

to delete mail from spammer@domain.com

I hope this helps!
 
  • Like
Reactions: dmlc and hata_ph
Thank you very much. Again I see my basic linux knowledge is not as it should be. Having this very good example helped so much in understanding mailq and postqueue. I was able to delete the mails I wanted, just using your code example :)
And yes I will post an enhancement request.
 
  • Like
Reactions: Stoiko Ivanov

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!