IMAP Grab

I originally wrote this to allow me to backup my Gmail account through IMAP. It is released under GPLv2.
You can browse the SVN at ImapGrab's SourceForge.net project page.

Current Version

ImapGrab Version 0.1.4 [ Download ]
Warning! This is an alpha release and should not be considered stable.

  • Note: The program is currently just two python scripts with some glade/svg files.

Description

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.

Features

  • 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

Dependancies

  • 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.

Bugs

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-lList the mailboxes available for download
--download-dDownload mailboxes to separate mbox files
--mbox-BDownload into Mbox format (optional, default)
--maildir-MDownload into Maildir format (optional)
--all-aForce download all mail in a mailbox (optional)
--ssl-SUse SSL connection (optional)
--server-sIP or domain of server (required)
--port-PPort of server (optional)
--username-uUsername for account (required)
--password-pPassword for account (required)
--mailboxes-mComma 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-fPath to folder (optional, creates imapgrab folder in current directory as default)
--localuser-LUser that writes to the mailboxes (use only when involking imapgrab as root)
--quiet-qDon't display any output
--verbose-vVerbose output
--debug Print debug output
--version Print version
--about Display detailed info
--help-hPrint 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

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