Deleting all e-mail messages in your inbox with mutt

Occasionally, I'll end up with a mailbox full of random data, alerts, or other useless things. If you have SSH access to the server, you can always clear out your mail spool, but if you connect to an IMAP server, you can use mutt to do the same thing.

First, use mutt to connect to your server remotely (via IMAP over SSL in this example):

mutt -f imaps://mail.yourdomain.com/

Once you've connected and logged in, press SHIFT-D (uppercase d). The status bar of mutt should show:

Delete messages matching:

Type in ~s .* so that the line looks like:

Delete messages matching: ~s .*

When you press enter, mutt will put a D next to all of the messages, which marks them for deletion. Press q to quit, and then y to confirm the deletion. After a brief moment, all of those messages will be deleted and mutt will exit.

Update: If you review Dmitri's comment below, there's an even faster way to remove all of the messages in a mailbox with mutt. Just hold shift while pressing D, ~ (tilde), and A to select everything:

D~A
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Printed from: http://rackerhacker.com/2009/06/19/deleting-all-e-mail-messages-in-your-inbox-with-mutt/ .
© Major Hayden 2010.

5 Comments   »

  • The easier way is:
    T~s .*;d$

    T to enable tag mode, ~s.* to select everything matching your subject (or .* for everything), and ;d to delete said tagged messages. The final $ will cause mutt to sync your changes to the mailbox if you don't want to quit.

  • Thanx for this great Tutorial!

  • Thanks a lot! I just did this with my 1600+ (junk) mutt messages. Really helpful.

  • ~s .* selects all messages by subjects. A better (IMHO) way to select all messages is:

    ~A

    It does not expect any regular expressions, it just selects everything. To mark all messages as deleted, press:

    D~A

  • Dmitri - that's a handy tip!

RSS feed for comments on this post , TrackBack URI

Leave a Reply