As a workaround, one of the following methods can be applied:
- Delete the mailbox from the server and create it again – all emails will be removed;
- Directly manipulate with Dovecot administrative utilities on a server:
Note: SSH access to the server is required.
Mailbox should be enabled: The “Mailbox” option is checked in Domains > example.com > Email Addresses > joedoe@example.com- Get the information about existing mailboxes:
- Get the information about existing mailboxes:
-
doveadm mailbox list -u user@example.com
INBOX
INBOX.Spam
INBOX.Drafts
INBOX.Trash
INBOX.Sent - Remove all messages older than a week from the
'Inbox'folder for the particular mailboxuser@example.com: -
doveadm expunge -u user@example.com mailbox ‘*’ before 1w
- Remove all messages older than a week from all folders except
'Inbox'folder for the particular mailboxuser@example.com: -
doveadm expunge -u user@example.com mailbox INBOX.’*’ before 1w
- Remove all messages from
'Drafts'folder on allexample.comdomain mailboxes: -
for i in $(plesk bin mail -l | tr ‘\t’ ‘ ‘ | cut -d’ ‘ -f 3- | grep example.com); do doveadm expunge -u “$i” mailbox INBOX.Drafts all; done
- Delete all messages from the particular mailbox
user@example.com: -
doveadm expunge -u user@example.com mailbox ‘INBOX’ all
# doveadm expunge -u user@example.com mailbox ‘INBOX.*’ all - Remove all messages from
'Spam'and'Trash'folders from all mailboxes on all domains: -
for i in $(plesk bin mail -l | tr ‘\t’ ‘ ‘ | cut -d’ ‘ -f 3-); do doveadm expunge -u “$i” mailbox INBOX.Spam all; done
# for i in $(plesk bin mail -l | tr ‘\t’ ‘ ‘ | cut -d’ ‘ -f 3-); do doveadm expunge -u “$i” mailbox INBOX.Trash all; doneNote: courier-imap does not support these commands
- Also the procedure can be optimized by deleting all emails for all mailboxes specified in a file:
- Download the following script and grant permissions:
- Download the following script and grant permissions:
-
wget https://support.plesk.com/hc/en-us/article_attachments/360009079459/script.sh
# chmod +x ./script.sh
- Edit/Create file mbox.txt and specify all mailboxes for you wish to remove emails from:
johndoe@example.com
…
jjohndoe2@example.org - Execute the script:
-
-
-
./script.sh
-
-
admin