Small utilities for managing IMAP email messages.
Displays a summary about the specified mailbox.
mailbox-summary.py [-h] --host HOST [-p PORT] [--user USERNAME] [--password PASSWORD] [--no-ssl] [--no-color] [-f FOLDER] [--quiet]
| Argument | Description |
|---|---|
-h, --help | shows the help |
--host | IMAP server host |
--password | user password (insecure, see below) |
--no-ssl | do not use SSL (insecure) |
--no-color | disable terminal colors |
-f, --folder | IMAP mailbox (default: Inbox) |
--quiet | do not show any errors or warnings |
The following command will show a summary about the Inbox folder of the justexample user on the Google Mail:
$ ./mailbox-summary.py --host imap.gmail.com --user justexample --password qwerty --folder Inbox
Sample output:
Connecting ...
Connected.
Logging in ...
Logged in.
Selecting mailbox ...
Fetching unseen messages IDs ...
Total messages: 3
Unseen: 2
Available mailboxes (folders):
(\HasNoChildren) "/" "INBOX"
(\Noselect \HasChildren) "/" "[Gmail]"
(\HasNoChildren \Important) "/" "[Gmail]/&BBIEMAQ2BD0EPgQ1-"
(\HasNoChildren \All) "/" "[Gmail]/&BBIEQQRP- &BD8EPgRHBEIEMA-"
(\HasChildren \HasNoChildren \Trash) "/" "[Gmail]/&BBoEPgRABDcEOAQ9BDA-"
(\HasNoChildren \Sent) "/" "[Gmail]/&BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-"
(\HasNoChildren \Flagged) "/" "[Gmail]/&BB8EPgQ8BDUERwQ1BD0EPQRLBDU-"
(\HasNoChildren \Junk) "/" "[Gmail]/&BCEEPwQwBDw-"
(\HasNoChildren \Drafts) "/" "[Gmail]/&BCcENQRABD0EPgQyBDgEOgQ4-"
Logging out ...
Success.
Downloads email messages from the specified IMAP folder.
download-folder.py [-h] --host HOST [-p PORT] [--user USERNAME] [--password PASSWORD] [--no-ssl] [--no-color] [-f FOLDER] [--quiet] [-d PATH] [--force]
| Argument | Description |
|---|---|
-h, --help | shows the help |
--host | IMAP server host |
--password | user password (insecure, see above) |
--no-ssl | do not use SSL (insecure) |
--no-color | disable terminal colors |
-f, --folder | IMAP mailbox (default: Inbox) |
--quiet | do not show any errors or warnings |
-d, --directory | download directory (default is the current directory) |
--force | overwrite files without prompt |
The following command will download all the Spam from the Google Mail account into the specified directory (replacing all existing files):
$ ./download-folder.py --host imap.gmail.com --user justexample --password justexample --force -d ~/Documents/Spam/ --folder "[Gmail]/Spam"
Sample output:
Connecting ...
Connected.
Logging in ...
Logged in.
Selecting mailbox ...
Fetching messages IDs ...
Found 3 message(s)
Got message #1 (5779 bytes) <000d01cdae8d$3419a4d0$00575fa8@xuysldrpkpota>
Saving as /home/eigenein/Documents/Spam/000d01cdae8d$3419a4d0$00575fa8@xuysldrpkpota.eml ...
Got message #2 (5740 bytes) <000d01c193a9$959c0230$00575fa8@eyxkcguufxqds>
Saving as /home/eigenein/Documents/Spam/000d01c193a9$959c0230$00575fa8@eyxkcguufxqds.eml ...
Got message #3 (5818 bytes) <000901cdaea3$28b11a90$00575fa8@sdvgdydcqj>
Saving as /home/eigenein/Documents/Spam/000901cdaea3$28b11a90$00575fa8@sdvgdydcqj.eml ...
Logging out ...
Success.