All Projects → jamesridgway → attachment-downloader

jamesridgway / attachment-downloader

Licence: MIT license
Simple tool for downloading email attachments for all emails in a given folder using an IMAP client

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to attachment-downloader

Mailspring
💌 A beautiful, fast and fully open source mail client for Mac, Windows and Linux.
Stars: ✭ 11,953 (+22886.54%)
Mutual labels:  email, imap
Mnm
The legitimate email replacement — n-identity, decentralized, store-and-forward, open protocol, open source. (Server)
Stars: ✭ 162 (+211.54%)
Mutual labels:  email, imap
Mail
Mail app designed for elementary OS
Stars: ✭ 130 (+150%)
Mutual labels:  email, imap
Imapcopy
Recursively copy all e-mail messages and folders from one IMAP account to another.
Stars: ✭ 52 (+0%)
Mutual labels:  email, imap
Mailer
A light-weight, modular, message representation and mail delivery framework for Python.
Stars: ✭ 225 (+332.69%)
Mutual labels:  email, imap
Inbrief
InBrief is a personal briefing app and dashboard powered by Electron and React
Stars: ✭ 90 (+73.08%)
Mutual labels:  email, imap
Mattermail
Email Integration for Mattermost
Stars: ✭ 145 (+178.85%)
Mutual labels:  email, imap
Imap
Object-oriented, fully tested PHP IMAP library
Stars: ✭ 678 (+1203.85%)
Mutual labels:  email, imap
Vmime
VMime Mail Library
Stars: ✭ 218 (+319.23%)
Mutual labels:  email, imap
Lumail
A console-based mail-client with integrated Lua scripting support.
Stars: ✭ 187 (+259.62%)
Mutual labels:  email, imap
How to get emails imap tutorial
How to get emails including there attachments and how to extract various attributes from those emails. See https://youtu.be/zFEEGkvo6O8 for a more detailed information.
Stars: ✭ 30 (-42.31%)
Mutual labels:  email, imap
Rust Imap
IMAP client library for Rust
Stars: ✭ 237 (+355.77%)
Mutual labels:  email, imap
Nioimapclient
High performance, async IMAP client implementation
Stars: ✭ 28 (-46.15%)
Mutual labels:  email, imap
Opaquemail
.NET email library and proxy supporting IMAP, POP3, and SMTP with S/MIME and PGP.
Stars: ✭ 91 (+75%)
Mutual labels:  email, imap
Kanmail
📥 An email client that functions like a kanban board.
Stars: ✭ 833 (+1501.92%)
Mutual labels:  email, imap
Magma
The magma server daemon, is an encrypted email system with support for SMTP, POP, IMAP, HTTP and MOLTEN,. Additional support for DMTP and DMAP is currently in active development.
Stars: ✭ 1,740 (+3246.15%)
Mutual labels:  email, imap
Sieve
Sieve Script Editor
Stars: ✭ 452 (+769.23%)
Mutual labels:  email, imap
Deltachat Desktop
Email-based instant messaging for Desktop.
Stars: ✭ 526 (+911.54%)
Mutual labels:  email, imap
Imap tools
Work with email and mailbox by IMAP
Stars: ✭ 167 (+221.15%)
Mutual labels:  email, imap
Mailu
Insular email distribution - mail server as Docker images
Stars: ✭ 3,151 (+5959.62%)
Mutual labels:  email, imap

Attachment Downloader

CI

Simple tool for downloading email attachments for all emails in a given folder using an IMAP client.

Install:

$ pip install attachment-downloader

Usage:

Usage: attachment-downloader [options]

Options:
  -h, --help            show this help message and exit
  --host=HOST           IMAP Host
  --username=USERNAME   IMAP Username
  --password=PASSWORD   IMAP Password
  --imap-folder=IMAP_FOLDER
                        IMAP Folder to extract attachments from
  --subject-regex=SUBJECT_REGEX
                        Regex that the subject must match against
  --date-after=DATE_AFTER
                        Select messages after this date
  --date-before=DATE_BEFORE
                        Select messages before this date
  --filename-template=FILENAME_TEMPLATE
                        Attachment filename (jinja2) template.
  --output=DOWNLOAD_FOLDER
                        Output directory for attachment download
  --delete              Delete downloaded emails from Mailbox
  --delete-copy-folder=DELETE_COPY_FOLDER
                        IMAP folder to copy emails to before deleting them
  --port=PORT           Specify imap server port (defaults to 993 for TLS and
                        143 otherwise
  --unsecure            disable encrypted connection (not recommended)
  --starttls            enable STARTTLS (not recommended)

Example:

$ attachment-downloader --host imap.example.com --username [email protected] --password pa55word \\
    --imap-folder invoices --output ~/Downloads

Messages from all folders

If you wish to search through all messages regardless of folder, omit the --imap-folder argument.

Date Filtering

Date filtering can be performed by specifying one or both of the date arguments:

--date-after="2021-02-06T13:00:00" --date-before="2021-02-06T13:25:00"

Dates should be provided in ISO format, e.g: 2021-02-06T13:25:00 or 2021-02-06T13:25:00.

If a zone offset is not provided UTC will be assumed.

Requirements

This tool requires Python 3+

This is not compatible with Python 2.

Filename Template

By default attachments will be downloaded using their original filename to the folder specified by -output.

You can customise the download filename using a jinja2 template for the argument --filename-template.

The following variables are supported:

  • message_id
  • attachment_name
  • attachment_idx
  • subject
  • date

In the following example, downloads will be placed within the output folder grouped into a folder hierarchy of date, message ID, subject:

--filename-template="{{date}}/{{ message_id }}/{{ subject }}/{{ attachment_name }}"

The datetime of the message can also be formatted in the output filename, for example:

--filename-template "{{date.strftime('%Y-%m-%d')}} {{ attachment_name }}"

Reporting Issues and Contributing

If you spot any issues or have a feature request please feel free to raise an issue, or even better, propose a pull request.

Testing

For local testing of the tool, a docker-compose stack is included which provides a Postfix, Dovecot, PostfixAdmin and Roundcube setup.

Docker compose can be run using

docker-compose up

The login for PostfixAdmin is root / L3tm31n

The following mailboxes will also be created which can be accessed via roundcube:

Mailbox Password
[email protected] Pass11
[email protected] Pass22
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].