Skip to content
  • Solutions
    By Role
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    By Infrastructure
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
  • Product
    • Plesk Features
    • Plesk Editions
    • What’s new
    • Pricing
    • Roadmap
    • Lifecycle Policy
    • Extensions Catalogue
  • Pricing
  • Extensions
    Featured Extensions
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    Bundles and packs:
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack

    See all Extensions

  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
Plesk 360 login
Free Trial

Knowledge Base

How to delete all or some emails from a mailbox without logging in to the mailbox on a Plesk server?

 
domainsdovecotemailfeaturesgithub

Question

How to delete all or some emails from a mailbox without logging in to the mailbox?

Answer

Right now this feature is not implemented in Plesk. Please vote for it on our Plesk UserVoice portal: the most popular features are likely to be included in one of the next Plesk versions.

As a workaround, one of the following methods can be applied:

  1. Delete the mailbox from the server and create it again - all emails will be removed;

  2. 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 > [email protected]

    • Get the information about existing mailboxes:

      # doveadm mailbox list -u [email protected]

      INBOX
      INBOX.Spam
      INBOX.Drafts
      INBOX.Trash
      INBOX.Sent

    • Remove all messages older than a week from the 'Inbox' folder for the particular mailbox [email protected]:

      # doveadm expunge -u [email protected] mailbox '*' before 1w

    • Remove all messages older than a week from all folders except 'Inbox' folder for the particular mailbox [email protected]:

      # doveadm expunge -u [email protected] mailbox INBOX.'*' before 1w

    • Remove all messages from 'Drafts' folder on all example.com domain 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 [email protected]:

      # doveadm expunge -u [email protected] mailbox 'INBOX' all
      # doveadm expunge -u [email protected] 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; done

      Note: 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:

        # wget https://github.com/plesk/kb-scripts/raw/master/mailbox-doveadm-expunge/mailbox-doveadm-expunge.sh && chmod +x ./mailbox-doveadm-expunge.sh

      • Edit/Create file mbox.txt and specify all mailboxes for you wish to remove emails from:

        [email protected]
        ...
        [email protected]

      • Execute the script:

        # ./mailbox-doveadm-expunge.sh

More information on these features could be found in official Dovecot documentation articles:

Doveadm-Search-Query

Doveadm-Expunge

Tweet
Share
Share
Email
0 Shares
Read the full article
Related Posts

Exploring Plesk’s Added Value Solutions So Far in 2023

Read More »

Unveiling Sitejet Builder: The Perfect Match for Your Effortless Website Creation Needs

Read More »

Dynamic List vs. Active List: A Comprehensive Comparison – Unveiling the Ultimate Winner!

Read More »
Knowledge Base

Websites on Plesk server are slow or show error 500 or PHP mail cannot be sent: ap_pass_brigade failed

Read More »

Can’t access mail: Warning: Inotify instance limit for user exceeded

Read More »

Mail delivery does not work: do not list domain in BOTH mydestination and virtual_mailbox_domains

Read More »

Email header analysis reports SPF failed for localhost IP on mail sent from Plesk hosted mailbox: SPF Authentication : SPF Failed for IP – 127.0.0.1

Read More »

Hosting Wiki

  • GIT
  • Server Redundancy
  • QMAIL
  • Dovecot
  • Sendmail
  • GitHub
  • Bare Metal Server
  • Oracle VM Server
  • Server Virtualization Software
  • Windows Server
  • Linux
  • Domain
  • Plesk
  • Web Server
  • DNS Server
  • SSH
  • Email Autoresponder
  • Mailing Lists
  • Email Alias
  • Email Virus Protection
  • Email Forwarding
  • Webmail
  • SpamAssassin
  • SPAM filter
  • SPAM
  • HTTP
  • IMAP
X-twitter Linkedin Youtube Reddit Github
  • Product
  • Login
  • Pricing
  • Editions
  • For Partners
  • Partner Program
  • Contributor Program
  • Affiliate Program
  • Plesk University
  • Company
  • Blog
  • Careers
  • Events
  • About Plesk
  • Our Brand
  • Resources
  • User and Admin guides
  • Help Center
  • Migrate to Plesk
  • Contact Us
  • Hosting Wiki
  • Forum
  • Legal
  • Legal
  • Privacy Policy
  • Imprint

© 2025 WebPros International GmbH

Part of the WebPros®  Family