On October 19, 2021, we have enabled single-sign-on for our Plesk Support Center to provide a seamless login/account experience. This implies that you’ll be able to use a single account across any of our web-facing properties.
If you had already registered your account at MyPlesk.com/Plesk360/Platform360 please use one for login. Otherwise please re-register it using the same email address as your existing Zendesk login (support account). It’s essential that you use the same email address on our support center to ensure that your tickets stay attached to the same account.

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

Follow

Comments

4 comments

  • Avatar
    Nathan Wilson

    Hi,

    I'm looking at running a daily job to delete all spam items older than 1 month (like Gmail does).

    Can I confirm this command will do the trick?

    for i in $(plesk bin mail -l | tr '\t' ' ' | cut -d' ' -f 3-); do doveadm expunge -u "$i" mailbox INBOX.Spam before 1m; done

    Thanks.

    0
    Comment actions Permalink
  • Avatar
    Anton Maslov (Edited )

    Nathan Wilson syntax looks correct, thought we do not test any anything like this to guarantee it will work for 100%.

    p.s. I would do a small change to your command to exclude aliases as they have no separate mailbox:

    for i in $(plesk bin mail -l | grep -v Alias| tr '\t' ' ' | cut -d' ' -f 3-); do doveadm expunge -u "$i" mailbox INBOX.Spam since 4weeks; done
    1
    Comment actions Permalink
  • Avatar
    Stavros T

    That is a great one! thanks for that. 

    This script solves a major problem with the clients that using gmail pop3 to get their emails.
    Gmail does not grab the spams and the plesk mailboxes getting full. 

     

    0
    Comment actions Permalink
  • Avatar
    Jason Millis

    Anton Maslov & Nathan Wilson, the `1m` in your snippets would remove all mails older than 1 minute.

    From dovecot's documentation, supported time units are:

    Available time units are: weeks (abbr: w), days (abbr: d), hours (abbr: h), mins (abbr: m) and secs (abbr: s).

    I've just made that mistake, thankfully it was only on my emails in the trash folders.

    I'd suggest you use 31d to cover the longest months.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Have more questions? Submit a request