IMAPImport
IMAPImport is a python script I wrote to import mail files into an IMAP server.
When my Cyrus IMAP server's hard drive crashed in May 2005, I struggled to get the backup of all my email
running on a new server. The new server was running a much newer version of Cyrus IMAP and I had all sorts
of issues trying to upgrade the existing mail databases and directory structure. I finally wrote
IMAPImport so I could a) get my mail back and b) learn Python. Both goals were accomplished.
IMAPImport will look for mail files under a specified directory and add them to a specified user's local
IMAP mailbox. IMAPImport will automatically create subfolders as it finds them in the directory structure.
The IMAP date field for each message is extracted from the Date header in the message itself.
Cyrus IMAP stores each email in its own file and each file's name ends in a period. Each
directory underneath a user's root folder corresponds to an IMAP folder under the user's INBOX. You'll
have to tweak the python script if your configuration is any different from this. Be aware that IMAPImport
does minimal error checking.
Usage
./IMAPImport.py /var/mailbackup/josh josh
This would cause IMAPImport to import all mail files under /var/mailbackup/josh into josh's mailbox on the local IMAP server.
Version History
- 5/28/2005 - Initial release
Requirements
- Python 2.3 or higher
- Tested on Linux (Fedora Core 3), but should run on any platform supported by Python
Download