Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Version 0.1 Released

13 views
Skip to first unread message

Daniel Roesler

unread,
Jan 7, 2009, 10:40:57 AM1/7/09
to ImapGrab Mailing List
Ahoy all,

Today is a good day. I finally finished the first version of IMAP Grab (v0.1).

The project originally spawned out of the need to back up my Gmail
account. When I searched for a tool to download my messages and keep
my labels intact, I found nothing special. Most IMAP download scripts
or programs for Ubuntu didn't allow selective download of mailboxes
(Gmail labels). GmailBackup only runs on Windows and is non-free (as
in freedom). So, I decided this would be a good opportunity for me to
learn python. It took me about a month to create ImapGrab 0.1.

IMAP Grab (official name, ImapGrab for short, imapgrab for command
line) is a python script that acts as a command line interface (cli).
It can connect to an IMAP server and list or download the available
mailboxes. For Gmail, mailboxes are called labels, but I want to keep
this program pretty generic, so I'm calling them mailboxes. The real
work for the program is done by getmail
(http://pyropus.ca/software/getmail/), and ImapGrab basically acts as
an automatic config file maker. ImapGrab will take a list of
mailboxes, download them from the server, and save them in separate
mbox files. For example, if you use ImapGrab to download messages in
the "receipts" and "mailing lists" labels from your Gmail account, you
will end up with "receipts.mbox" and "mailing lists.mbox" in a folder.

There are basically two overall options in the ImapGrab cli: --list
and --download. List will print a list of mailboxes on the server.
Download will download the mailboxes in the --mailboxes option to
separate mbox files.

Since this project was started with the goal to backup my Gmail
account, I included a special option ("-_Gmail_") to omit [Gmail]*
mailboxes from the "_ALL_" option. It just makes the command I use
shorter. You can still individually omit them, but this omits [Gmail],
[Gmail]/Starred, [Gmail]/Sent Mail, [Gmail]/Drafts, [Gmail]/All Mail,
[Gmail]/Spam, and [Gmail]/Trash with one option.

This program depends on python 2.5.2 or higher (it may only need
python 2.4, but I haven't tried this) and getmail 4.8.2 or higher.

I've created a temporary webpage for the program on my website:
http://daylightpirates.org/index.php/Programs/ImapGrab

I have some ideas where I want the project to go:
-Add wildcard handling for mailbox list (i.e. "[Folder]/*")
-Add a gui, so it can compete with GmailBackup
-Make Mac and Windows compatible
-Create packages for easy installation (deb, rpm, msi)
-Address security concerns

Here is the usage description from imapgrab-0.1.py:
# 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
# --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]* folders)
# (required for -d)
# --folder, -f Path to folder
# (optional, creates imapgrab folder in current
directory as default)
# --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

Here are some examples of the cli:
# 1) List available mailboxes
# imapgrab -l -s imap.example.com -u username -p password
# 2) 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"
# 3) Download all mailboxes except "box3"
# imapgrab -d -s imap.example.com -u username -p password -m
"_ALL_, -box3"
# 4) Download all Gmail custom labels and INBOX (none of the [Gmail]*
mailboxes)
# imapgrab -d -S -s imap.gmail.com -u username -p password -m
"_ALL_, -_Gmail_"
# 5) Download Gmail label "receipts"
# imapgrab -d -S -s imap.gmail.com -u username -p password -m "receipts"

My

unread,
Jan 7, 2009, 12:16:00 PM1/7/09
to imapgrab
> ... <snip> ...

Good day Daniel!

Because of my eternal quest for the "perfect" IMAP copy/move utility I
was very happy about your announcement.

Great work! Gave it a try and here are my results:

It was able to list all the folders and sub-folders in the IMAP
account.

It was able to download one or more folders (I didn't try "ALL").

I'm no programmer but was wondering if it may be possible to add
Maildir delivery capability?

Thank you for sharing it.

My best regards.

--
My
Reply all
Reply to author
Forward
0 new messages