How to delete all the emails in Quarantine

cocconi

Renowned Member
Nov 5, 2009
15
8
68
Nouma, New Caledonia
Hi
I need to delete all the emails in the quarantine.
I know it should be done by the RCPT, but in this case (bad) SENDERS are in my network.
I can't wait the end of quarantine delay, I need to empty all before it.
I already try
'rm /var/spool/pmg/spam /*/*'
but it only delete the files, not the rcpt list in the web interface.
I've try some pmgsh commands without success too (it's need to delete email ID per email ID for each user)
If someone has the answer it 'll be great !

Thanks :)
 
You can delete mail queue from Administration -> Queues -> Deferred Mail.
 
I've tried several commands using pmgsh to delete all spam and Virus quarantine emails at once ...
 
I've made a perl script finaly (as PMG is perl it was easier).
If any is interest to use it .
syntax :
delete_quarantine.pl -f <from> -r <rcpt> -u <subject> -a <action>
action is mandatory : count/list/remove
it needs at least one : sender, rcpt or subject ; you can mix several

You can search for a sender, a recipient or some text in the subject, or a mixed of all of this.
And you must say which action you want to do.
It works for me, on PMG : pmg-api/6.1-5/e367e6d1

You have to rename it to *.pl, it's forbidden to upload pl files.
 

Attachments

  • delete_quarantine.txt
    3.3 KB · Views: 89
very very good !!
I renamed it "pmgdq" and put it in / usr / bin / next to "pmgsh"
I think the team could evaluate putting this tool in an official way, and even implement it in the GUI ....


Could you add two functions?

1 - Send emails (currently only have to remove)
2 - Send / Remove EVERYTHING in quarantine
 
Last edited:
I've made some changes & corrections :
- new delivery action
- action to all emails in quarantine if the from or the rcpt is named 'allemails'
- the from check is done vs the 'from' and no more the 'enveloppe_sender'
- the output is now printed 'From' & 'Rcpt'
- the script is named 'pmgdq ', thanks to 'thiagotgc' ;)

Hope it can be usefull
 

Attachments

  • pmgdq.txt
    4.1 KB · Views: 93
Great! Great job! It will help a lot!

Is it possible to carry the code for virus quarantine messages?
 
The script is a godsend.It allow me to remove/deliver bulk mail from quarantine.
It is a good idea to implement this on PMG GUI.
 
Btw, how to search subject using the script?
I try pmgdq -u Anthony -a count but not working...
 
I've made some changes & corrections :
- new delivery action
- action to all emails in quarantine if the from or the rcpt is named 'allemails'
- the from check is done vs the 'from' and no more the 'enveloppe_sender'
- the output is now printed 'From' & 'Rcpt'
- the script is named 'pmgdq ', thanks to 'thiagotgc' ;)

Hope it can be usefull
What i am getting as response is this output:
delete_quarantine.pl -f MAILER-DAEMON@mydomain.local.in -a count 400 Parameter verification failed. pmail: value does not match the regex pattern get quarantine/spam [OPTIONS] malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at bin/delete_quarantine.pl line 110.

On line 110 is:

... my $jspam= qx(/usr/bin/pmgsh get /quarantine/spam --starttime $starttime --endtime $endtime -pmail $u->{'mail'} 2>/dev/null); -> my $emails = decode_json($jspam); foreach my $em (@$emails){ ...
 
What i am getting as response is this output:
delete_quarantine.pl -f MAILER-DAEMON@mydomain.local.in -a count 400 Parameter verification failed. pmail: value does not match the regex pattern get quarantine/spam [OPTIONS] malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at bin/delete_quarantine.pl line 110.

On line 110 is:

... my $jspam= qx(/usr/bin/pmgsh get /quarantine/spam --starttime $starttime --endtime $endtime -pmail $u->{'mail'} 2>/dev/null); -> my $emails = decode_json($jspam); foreach my $em (@$emails){ ...
it must be add >'< between $u->{'mail'}

my $jspam= qx(/usr/bin/pmgsh get /quarantine/spam --starttime $starttime --endtime $endtime -pmail '$u->{'mail'}' 2>/dev/null);

Greetings.

More fixes should be welcome.

Errores show up with mails like following one:

a/h8uvt0aseoxwpvjbwe1fq==_1109382361974_khyiyoo8eemu3dsuuple3q==@in.constantcontact.com
 
Last edited:
it must be add >'< between $u->{'mail'}

my $jspam= qx(/usr/bin/pmgsh get /quarantine/spam --starttime $starttime --endtime $endtime -pmail '$u->{'mail'}' 2>/dev/null);

Greetings.

More fixes should be welcome.

Errores show up with mails like following one:

a/h8uvt0aseoxwpvjbwe1fq==_1109382361974_khyiyoo8eemu3dsuuple3q==@in.constantcontact.com
I have update my proxmox and this kind of problem has been solved.

Greetings.
 

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!