Deleting all messages from mailbox (not queue) by sender

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
Post Reply
smclinden
Posts: 24
Joined: Mon Aug 28, 2017 7:54 pm

Deleting all messages from mailbox (not queue) by sender

Post by smclinden »

Is it possible to remove all mail from a given sender using the command line (e.g. zmmailbox)?

I've been inundated with automated emails (like GitHub) and the size of the mailbox is growing exponentially. I see methods for deleting from the queue but not the mailbox in the forum.
liverpoolfcfan
Elite member
Elite member
Posts: 1096
Joined: Sat Sep 13, 2014 12:47 am

Re: Deleting all messages from mailbox (not queue) by sender

Post by liverpoolfcfan »

Don't know of an easy way from the command line but, you can easily

1. Create a new folder - ToBeDeleted
2. Open one of the emails in your Inbox
3. Right-click on the From Address bubble and select "Received From Sender"
4. Check the contents of the list of emails. If you need to be more selective, add an additional Subject:whatever filter
5. When you are happy with the list, note the selection criteria used, then Click the Select-All [ ] at the top of the list
6. If you see the notification that there are many more matching emails then press Ctrl-Shift-A to select ALL matching emails
7. Click the Move (Folder) icon and select the "ToBeDeleted" folder
8. Check the ToBeDeleted folder contents to make sure nothing you wanted to keep slipped through the filter. If any did, then move everything back to Inbox, go back to Step 4 and adjust the selection criteria
9. Right-click folder ToBeDeleted and select Empty Folder
10. Go to Preferences->Filters->Incoming Message Filters and add a new filter matching your selection criteria from step 5 with Action "Move into folder" "ToBeDeleted" and check [ ] Do not process additional filters - this should automatically handle new incoming emails for you
10. Repeat for other unwanted emails

Once you have cleaned up sufficiently, as new emails arrive from the various sources they will automatically filter into the ToBeDeleted folder. Check it periodically to make sure nothing wanted got through your filters, and Empty the Folder
smclinden
Posts: 24
Joined: Mon Aug 28, 2017 7:54 pm

Re: Deleting all messages from mailbox (not queue) by sender

Post by smclinden »

Thanks. As you said, that works but given that I have half a million messages in my inbox, the Web front-end keeps timing out.

I can live with that but would be easier if there was a cli way to do that.
User avatar
ccelis5215
Outstanding Member
Outstanding Member
Posts: 632
Joined: Sat Sep 13, 2014 2:04 am
Location: Caracas - Venezuela
ZCS/ZD Version: 8.8.15.GA.3869.UBUNTU18.64 P12

Re: Deleting all messages from mailbox (not queue) by sender

Post by ccelis5215 »

smclinden wrote:Thanks. As you said, that works but given that I have half a million messages in my inbox, the Web front-end keeps timing out.

I can live with that but would be easier if there was a cli way to do that.
Look at https://wiki.zimbra.com/wiki/Deleting_m ... ng_the_CLI

something like

Code: Select all

su - zimbra -c "zmmailbox -z -m account@mydomain s -t message -l 1000 "from:thesender@senderdomain"|awk '{ if (NR>4 && NF) {print \"dm\", \$2}}'"
Hope it helps.

ccelis
Post Reply