Using Telnet to Delete Mass Amounts of E-mail

For whatever reason, you may end up with a huge amount of e-mail stuck on a mail server and it all just needs to go. Maybe you’ve been lax in clearing e-mail, your e-mail application isn’t managing your mailbox properly or perhaps you’ve just been spammed into oblivion.

However, if you’ve got hundreds or even thousands of messages on the mail server that need to be deleted you’re probably not looking forward to manually deleting each and everyone one:

user <username>

pass <password>

stat

dele 1

dele 2

dele 3

….

dele x – 1

dele x

Luckily, there is a smarter way to do this using Microsoft Excel using some easy steps. But first, a warning:

Undertaking the following will delete most, if not, all of your e-mail from your mailbox – only proceed if you understand that you are deleting your e-mail!

Microsoft Excel - Generating Telnet Delete Commands

Microsoft Excel – Generating Telnet Delete Commands

  1. In cell A1, type in dele and press Tab,
  2. In cell B1, type in 1 and press Tab,
  3. In cell C1, type in the following formula then press Enter:
    1. =A1&” “&B1
  4. Highlight cells A1 to C1 and drag down for as many rows that you require,
  5. Copy the resulting text in Column C into your active telnet session,
  6. Watch your telnet window go nuts,
  7. Type quit and press Enter to confirm the deletions.

You might not need to use this tip all that often but always worth knowing just in case.

6 comments

Skip to comment form

    • Mark on May 1, 2013 at 21:58
    • Reply

    You legend!!!!!!!!

    Thanks for the advice. I just deleted 10,000 emails from my wife’s email account. It as been a nightmare. I called Telstra and they put it in the too hard basket, referred me to some Tech support in Malaysia ( who wanted to charge me $100) to clean out mail!!
    I had accessed Telnet server but was deleting one at a time. Then found your tip, today.

    THANKYOU my wife blames me for everything ( like it was my fault she doesn’t delete spam), so now I’m not as deep in it.
    ( always in the s##t, it’s only the depth that varies)

    P.s. it still takes a while if you have heaps f mail to delete. Just paste the excel file, hit enter, once it lists all the files, hit quit, them it just sits there for up to 10 minutes , just leave it

    Cheers
    Mark

    1. That’s an awesome result for you!

      It’s a bit odd that Telstra wouldn’t help you out – I actually worked there in technical support in a previous life and we would delete large e-mails or even clear the mailbox out. We had a very handy tool to do it as well back in the day.

      Anyway, glad that it will help get you in the good books again (even though it’s not your fault)!

    • Scott Bartgis on January 5, 2019 at 00:48
    • Reply

    I know this is quite old, but I’d like to offer a way to accomplish this in Excel with a single column:

    In Cell A1 enter this formula:

    =”DELE ” & ” ” & ROW()

    Now just highlight/drag A1 down as far as you want. I do 2,000 per session.

    • Sean Vinsick on February 14, 2019 at 04:11
    • Reply

    Try python:

    import poplib
    M = poplib.POP3(‘popserver’,110) #assuming no encrypt,
    M.user(‘username’)
    M.pass_(‘password’)
    print(‘There are %d messages’ % M.stat()[0])
    for i in range(1,M.stat()[0]):
    M.dele(i)
    print(‘There are now %d messages’ % M.stat()[0])
    M.quit()

  1. Neat idea, Boyd!

    Here’s another simple method to generate the list using just bash, which works under most *nixes (including OS X / macOS) and even Windows with Cygwin, WSL, etc:

    $ printf “%s\n” dele{1..5}
    dele1
    dele2
    dele3
    dele4
    dele5

    nixCraft offers a bash script to eliminate the need to copy/paste, and they also link to a PHP version.

    1. Sorry – should have been:

      $ printf “%s\n” dele\ {1..10}
      dele 1
      dele 2
      dele 3
      dele 4
      dele 5

      to include a space between “dele” and the number.

Leave a Reply to Boyd Chan Cancel reply

Your email address will not be published.