Skip to content
  • Contact us: +34 944 58 06 58
  • Plesk Partner Program
  • Plesk Lifecycle Policy
  • Blog
  • Contact us
  • Plesk 360
  • Contact us: +34 944 58 06 58
  • Plesk Partner Program
  • Plesk Lifecycle Policy
  • Blog
  • Contact us
  • Plesk 360
  • Solutions
    By Role
    • Developers
    • Content Managers
    • Digital Agencies
    • IT Admins
    • Web Hosters
    • Hyperscalers
    • Developers
    • Content Managers
    • Digital Agencies
    • IT Admins
    • Web Hosters
    • Hyperscalers
    By Edition
    • Web Admin Edition
    • Web Pro Edition
    • Web Host Edition
    • Business & Collaboration
    • Plesk WP Edition
    • Web Admin Edition
    • Web Pro Edition
    • Web Host Edition
    • Business & Collaboration
    • Plesk WP Edition
    By Cloud
    • Amazon Web Services
    • Microsoft Azure
    • Alibaba Cloud
    • GCP Marketplace
    • Vultr
    • DigitalOcean
    • Linode
    • UpCloud
    • Amazon Web Services
    • Microsoft Azure
    • Alibaba Cloud
    • GCP Marketplace
    • Vultr
    • DigitalOcean
    • Linode
    • UpCloud
    Partner Program
    Exclusive discounts, benefits and exposure to take your business to the next level
    Become a partner
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    Explore Features
    • Everyone
    • Admins & Web Hosters
    • Developers
    • Designers & Agencies
    • Plesk Features
    • Everyone
    • Admins & Web Hosters
    • Developers
    • Designers & Agencies
    • Plesk Features
    Key Topics
    • SocialBee
    • WP Toolkit
    • Sitejet Builder
    • SEO Toolkit
    • Joomla! Toolkit
    • Plesk Premium Email
    • Plesk Email Security
    • SocialBee
    • WP Toolkit
    • Sitejet Builder
    • SEO Toolkit
    • Joomla! Toolkit
    • Plesk Premium Email
    • Plesk Email Security
    Feature Packs
    • Business & Collaboration
    • WP Pack
    • Hosting Pack
    • Power Pack
    • Language Pack
    • Business & Collaboration
    • WP Pack
    • Hosting Pack
    • Power Pack
    • Language Pack
    Featured Extension
    SocialBee
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • Extension
  • Pricing
  • Extensions
  • Help Center
  • More
    • Careers
    • Events
    • Plesk University
  • FREE TRIAL
  • Solutions
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder
      • SEO Toolkit
      • Joomla! Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • SocialBee
  • Pricing
  • Extensions
  • Help center
  • More
    • Careers
    • Events
    • Plesk University
    • Blog
    • Plesk Partner Program
    • Contact Us
  • FREE TRIAL
  • Solutions
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder
      • SEO Toolkit
      • Joomla! Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • SocialBee
  • Pricing
  • Extensions
  • Help center
  • More
    • Careers
    • Events
    • Plesk University
    • Blog
    • Plesk Partner Program
    • Contact Us
  • 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

Industry
Partners

industry-partner_ALIBABA
industry-partner_GOOGLEPARTNER
industry-partner_MICROSOFT
industry-partner_REDHAT-r2
industry-partner_ALIBABA
industry-partner_AUTOMATTIC
industry-partner_AWS
industry-partner_DIGITALOCEAN
industry-partner_SCALEWAY
Follow us:
Facebook Twitter Linkedin Youtube Github

COMPANY

About Plesk
Our Brand
Legal
Careers
Impressum

PRODUCT

Pricing 
Extensions
What’s new

KNOWLEDGE BASE

Documentation
Help Center
Migrate to Plesk
Contact Us
Hosting Wiki
Preview releases

PROGRAMS

Contributor Program NEW
Partner Program
Affiliate ProgramNEW

COMMUNITY

Blog
Forums 
Plesk University

First defaul

Company

About Plesk
Our Brand
Legal
Careers
Impressum

PRODUCT

Pricing 
Extensions
What’s new

KNOWLEDGE BASE​

Documentation
Help Center
Migrate to Plesk
Contact Us
Hosting Wiki
Preview releases

PROGRAMS​

Contributor Program NEW
Partner Program
Affiliate ProgramNEW

COMMUNITY​

Blog
Forums
Plesk University

Follow us:
Facebook Twitter Linkedin Youtube Github

© 2025 WebPros International GmbH. All rights reserved. Plesk and the Plesk logo are trademarks of WebPros International GmbH.

Managed with love with Plesk WP Toolkit