I originally wrote this to allow me to backup my Gmail account through IMAP, but am no longer able to maintain it. It is released under GPLv2, so you are welcome to fork the project.


ImapGrab is a cli and gui program (written in Python) that allows you to log into an IMAP server, list mailboxes, and download selected mailboxes to mbox or maildir files. It requires getmail 4.8.2 or higher. The gui requires PyGtk 2.0 or higher.

Current Version

ImapGrab Version 0.1.4 (Download)

Screenshot thumbnail

Project Members:

Warning! This is an alpha release and should not be considered stable. The program is currently just two python scripts with some glade/svg files.


imapgrab.py is a command line interface (CLI) that allows you to log into an IMAP server and download selected mailboxes (i.e. folders/labels) to mbox files or maildir folders. You can also list the mailboxes on that server. It is basically a wrapper for getmail (a mail downloading program). When done downloading selected mailboxes, you end up with one .mbox file per mailbox or one set of maildir folders per mailbox.

imapgrab-gui.py is a graphical user interface (GUI) that is a wrapper for the imapgrab.py CLI. It must be run in the same directory as imapgrab.py and must have imapgrab-gui.glade, imapgrab-gui-about.glade, and imapgrab_logo_plain.svg in the same directory.


  • GUI for easy listing/downloading
  • Download in Mbox or Maildir formats
  • SSL connections possible
  • multiple select mailboxes may be downloaded in one command
  • all available folders may be downloaded
  • folders may be excepted when above is enabled
  • when mbox file is detected, only new mail is downloaded, but this can be changed (with -a)
  • special option to except Google Mail (Gmail) folders from download
  • GUI preset for Gmail's server settings


  • getmail 4.8.2 or higher
  • python 2.5.2 or higher
  • PyGtk 2.0 or higher (for imapgrab-gui.py only)

Mailing List

ImapGrab has a mailing list at Google Groups. I am always looking for more help developing this.


Currently, there isn't a formal bug tracker, so the best place to report bugs is the mailing list.

CLI Usage

imapgrab [-ldaSv] [-s] SERVER [-P] PORT [-u] USERNAME [-p] PASSWORD [-m] "BOX1,BOX2,..." [-f] DIRECTORY

Possible arguments

  • --list -l
    • List the mailboxes available for download
  • --download -d
    • Download mailboxes to separate mbox files
  • --mbox -B
    • Download into [[http://en.wikipedia.org/wiki/Mbox|Mbox]] format (optional, default)
  • --maildir -M
    • Download into [[http://en.wikipedia.org/wiki/Maildir|Maildir]] format (optional)
  • --all -a
    • Force download all mail in a mailbox (optional)
  • --ssl -S
    • Use SSL connection (optional)
  • --server -s
    • IP or domain of server (required)
  • --port -P
    • Port of server (optional)
  • --username -u
    • Username for account (required)
  • --password -p
    • Password for account (required)
  • --mailboxes -m
    • Comma separated list of mailboxes to download (i.e. "Box1, Box2, Box3") ({,} for non-separating commas) ("_ALL_" for all mailboxes) ("_ALL_, -Box1" to except Box1 from ALL) ("_ALL_, -_Gmail_" to except Gmail* and Google Mail* folders) (required for -d)
  • --folder -f
    • Path to folder (optional, creates imapgrab folder in current directory as default)
  • --localuser -L
    • User that writes to the mailboxes (use only when involking imapgrab as root)
  • --quiet -q
    • Don't display any output
  • --verbose -v
    • Verbose output
  • --debug
    • Print debug output
  • --version
    • Print version
  • --about
    • Display detailed info
  • --help -h
    • Print help with command options

CLI Examples

  • List available mailboxes
    • imapgrab -l -s imap.example.com -u username -p password
  • Download "box1" and "box2" from server imap.example.com (save "box1.mbox" and "box2.mbox")
    • imapgrab -d -s imap.example.com -u username -p password -m "box1, box2"
  • Download all mailboxes except "box3"
    • imapgrab -d -s imap.example.com -u username -p password -m "_ALL_, -box3"
  • Download all Gmail custom labels and INBOX (none of the Gmail* or Google Mail* mailboxes)
    • imapgrab -d -S -s imap.gmail.com -u username -p password -m "_ALL_, -_Gmail_"
  • Download Gmail label "receipts"
    • imapgrab -d -S -s imap.gmail.com -u username -p password -m "receipts"

Roadmap (Abandoned. No new versions planned.)

Version 0.2

  • create documentation
    • bug tracker
    • faqs
    • manual
  • secure password storage?
    • in rcfiles
    • in command itself
  • re-evaluate where to store files for getmail (oldmail in particular)
  • Maildir support done in version 0.1.1
  • Nested folder support done in version 0.1.1
  • Allow LIST that doesn't have quotations surrounding mailbox done in version 0.1.2
  • address infinite timeout for incorrect port or ssl connection

Version 0.3

  • wildcards in --mailboxes list (i.e. "[Folder]/*")

Version 0.4

  • Package for easy installation
    • deb
    • rpm
    • yum

Version 0.5

  • GUI interface done in version 0.1.3
  • add ability to create GUI presets

Version 1.0

  • Compatibility with Mac & Windows
    • Windows could be hard since getmail requires Cygwin

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks