__ __ __
____/ /___ _/ /_/ /______
/ __ / __ `/ __/ __/ ___/
/ /_/ / /_/ / /_/ /_(__ )
__,_/__,_/__/__/____/
Download and save attachments from IMAP server
This simple tool lets you download and save attachments from your e-mails. It should work with any mail service providers that support IMAP protocol, including free gmail.com, outlook.com, yahoo.com etc. It supports simultaneous connections and you can interrupt download process by pressing Ctrl+C - it will exit gracefully.
git clone https://github.com/krzysztof-nowakowski/datts.git
or hit Download button
./datts.py --help
Usage: ./datts.py --login --mbox --dir --server [--n] [--c] [--delete] [--dump] [--noinline] [--help]
Option Argument Description
-------------------------------------------
--help show this help
--login string login to your account
--server string server name
--mbox string remote folder with attachments
--dir string local folder for storing attachments
--n number how many messages to download? Default is all of them.
--c number how many connections to start? Default is 1, max is 10.
--delete should we delete message after download? Default is to NOT delete.
--dump print provided options and exit
--noinline skip attachments embedded in message body text
./datts.py --login name --server imap.gmail.com --mbox fun_stuff --dir backup/
./datts.py --login name --server outlook.office365.com --mbox inbox --dir backup/ --n 100 --delete
./datts.py --login name --server imap.gmail.com --mbox fun_stuff --dir backup/ --c 5
A: From your mail service provider, also check your account settings or maybe on one of this sites:
A: Default is to leave them in mailbox unless you specify --delete
option. Keep in mind that this is permanent deletion, you won't find deleted emails in your Trash/Bin folder.
A: If you don't download all of the attachments at first run and run datts again, it will download the same messages next time and write them to disk with slighty changed names. This is to avoid data overwriting as you may have more than one attachmet named the same name.
--noinline
option do?A: When you create email and insert for eg. image in the text, it will become "inline attachment". Sometimes you don't want to download this type of files as often they are logos, banners or similiar garbage.
SERVER_PORT = 993
in the code
to whatever is needed.