Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I empty gmail inbox from bash or sh? Can it be done using gmail POP3 server pop.gmail.com:995 or imap? I found a way to read emails via atom but it seems that it does not work via POP3 so the emails stay in the inbox.

share|improve this question
    
Please don't double-post: serverfault.com/questions/345654/empty-gmail-inbox-from-bash –  ziesemer Jan 1 '12 at 5:40

3 Answers 3

Connect to Gmail IMAP using any console IMAP client:

  • mutt:

    mutt -f "imaps://imap.gmail.com/INBOX"
    

    ShiftT.EnterdShift$

  • alpine, re-alpine

    alpine -f "{imap.gmail.com/ssl}INBOX"
    
  • heirloom-mailx, GNU mailutils

    mail -f "imaps://imap.gmail.com/INBOX"
    

    Delete all: d *q

  • Python:

    import imaplib
    im = imaplib.IMAP4_SSL("imap.gmail.com")
    im.login("user", "passwd")
    typ, data = im.search(None, 'ALL')
    for num in data[0].split():
        im.store(num, '+FLAGS', '\\Deleted')
    im.expunge()
    
share|improve this answer

you can use poplib module of python to check the mail and delete it accordingly see this for details

share|improve this answer

I guess you can do it quickly by logging in via the web. Click on the checkbox on the top of the list. This will select the first page mails. Now you will notice a link which will have a text which goes like "All xx conversations on this page are selected. Select all xxx conversations in Inbox" where xx is the number of conversations you see in the page and xxx is the number of total mails. Click on that link and then click on the bin icon (Delete). This will delete all your inbox. Follow the similar procedure for the outbox and drafts. Done!

share|improve this answer
1  
While this accomplishes the end result, Nutel is interested in doing this through bash or the terminal. –  iglvzx Jan 1 '12 at 5:58
    
@iglvzx Maybe this can be done in Lynx? –  Daniel Beck Jan 1 '12 at 13:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.