|
1 | 1 | IMAP Summary Script
|
2 | 2 | ===================
|
3 | 3 |
|
| 4 | +Connects to the specified IMAP server using the supplied credentials, queries all mailboxes |
| 5 | +(as returned by [IMAP4.list()](http://docs.python.org/3.1/library/imaplib.html#imap4-objects)) |
| 6 | +and pretty prints a summary of the folders. |
| 7 | + |
| 8 | +The username and password can be specified on the command line, but will be prompted for if |
| 9 | +not supplied. |
| 10 | + |
| 11 | +The summary can be sorted according to name, size or number of messages (ascending or descending) |
| 12 | + |
| 13 | +### Usage ### |
| 14 | + |
| 15 | +Use Python 3! |
| 16 | + |
| 17 | + usage: imap_folder_summary.py [-h] [--username USERNAME] [--password PASSWORD] |
| 18 | + [--no-tls] [--sort {name,num_msgs,size}] |
| 19 | + [--sort-reverse] |
| 20 | + hostname port |
| 21 | + |
| 22 | + Display a summary of all folders in an IMAP account |
| 23 | + |
| 24 | + positional arguments: |
| 25 | + hostname The IMAP hostname |
| 26 | + port The IMAP port number (eg 993) |
| 27 | + |
| 28 | + optional arguments: |
| 29 | + -h, --help show this help message and exit |
| 30 | + --username USERNAME The username (will prompt if not provided) |
| 31 | + --password PASSWORD The password (will prompt if not provided) |
| 32 | + --no-tls Specify to use IMAP instead of IMAP_SSL module |
| 33 | + --sort {name,num_msgs,size} |
| 34 | + Sort output by foldername, num messages, or size |
| 35 | + (bytes) |
| 36 | + --sort-reverse Specify to reverse sort output |
| 37 | + |
| 38 | + |
| 39 | +### Sample output ### |
| 40 | + |
| 41 | + ~> python imap_folder_summary.py imap.somewhere.com 993 --sort=size |
| 42 | + Username: eve |
| 43 | + Password: |
| 44 | + |
| 45 | + Name No. Msgs Size(b) Size(txt) |
| 46 | + "VacationStuff" 133 1015676 991.87KB |
| 47 | + "Work.ProjectA" 240 1734018 1.65MB |
| 48 | + "Friends.Alice" 685 1777753 1.70MB |
| 49 | + "Work.ProjectB" 274 1954619 1.86MB |
| 50 | + "Projects" 788 2832524 2.70MB |
| 51 | + "Friends.Bob" 298 4180646 3.99MB |
| 52 | + "INBOX" 951 15076086 14.38MB |
| 53 | + "archive" 2027 24877812 23.73MB |
| 54 | + |
| 55 | + """ |
0 commit comments