imapfetch — Fetch/Save IMAP Email Folders

This is imapfetch, a Python script that both demos the IMAP email interfaces in Python, and provides a utility you can use to download your email with this interface so you can process it with the PyMailGUI program. The net effect is a work-around for email providers that have denigrated POP email in recent years; PyMailGUI doesn't do IMAP, but it can still be used to process email fetched that way.

Overview

This short Python 3.X command-line program fetches all messages from all (or selected) email folders at an email account host, using the IMAP interface. POP provides access to the inbox only; IMAP is more complex and not universally supported, but also gives access to all other saved-mail folders at the host (e.g., sent mails, drafts, etc.).

Mails fetched from the server are saved in one local file per folder, but not removed from the server. The saved-mail files created by this script on your computer are designed to be viewed and processed offline with the PyMailGUI program, which also illustrates POP and SMTP email processing, and swaps IMAP folders for local saved-mail files. For more on using PyMailGUI to process email files saved by imapfetch, click here.

Resources

See the main script's docstring and other items below for usage details.

Code and docs:

Examples:

Download

Use the following to fetch imapfetch, or view its unzipped content.

This program was last changed: December 2015.

Recent upgrades: though not a change in the imapfetch script itself, the companion program used to view imapfetch saved-mail files changed substantially in 2017—PyMailGUI's display now looks like this and this on Mac OS X, and similar elsewhere. See PyMailGUI's home page for more details; some of the screenshots above are from its prior release, but work the same.

For more code examples, see the programs page.



[Home page] Books Code Blog Python Author Train Find ©M.Lutz