This project is an IMAP attachment daemon that automatically downloads email attachments from a specified IMAP server and saves them to a local directory.
This project was inspired by Calibre-Web-Automated and its Automatic Ingest Service, as well as Amazon's Send to Kindle feature. It aims to provide an easy way of adding ebooks to your calibre library while on the go through email.
- Connects to an IMAP server
- Downloads email attachments
- Saves attachments to a specified directory
- Supports whitelisting email addresses and email aliases
-
Clone the repository:
git clone https://github.com/joaommartins/imap-attachment-daemon.git cd imap-attachment-daemon
-
Create and configure the
.env
file:cp .env.example .env # Edit the .env file with your configuration
Edit the .env
file with your IMAP server details and other configurations:
CWA_IMAP_SERVER = "your_imap_server"
CWA_USERNAME = "your_username"
CWA_PASSWORD = "your_password"
CWA_ATTACHMENTS_DIR = "./attachments"
CWA_IMAP_SERVER
: The IMAP server address.CWA_USERNAME
: The username for the IMAP server.CWA_PASSWORD
: The password for the IMAP server.CWA_ATTACHMENTS_DIR
: The directory to save attachments.
CWA_TARGET_ADDRESS
: The email address to filter attachments.CWA_WHITELIST
: A comma-separated list of email addresses to whitelist.CWA_ACCEPTED_FILE_TYPES
: A comma-separated list of accepted file types for attachments. Defaults to:azw
,azw3
,azw4
,mobi
,cbz
,cbr
,cb7
,cbc
,chm
,djvu
,docx
,epub
,fb2
,fbz
,html
,htmlz
,lit
,lrf
,odt
,pdf
,prc
,pdb
,pml
,rb
,rtf
,snb
,tcr
,txtz
.
You can run the project directly using cargo run
:
-
Ensure you have Rust installed. If not, install it from rustup.rs.
-
Run the project:
cargo run
You can also run the project using docker run
:
-
Build the Docker image:
docker build -t imap-attachment-daemon .
-
Run the Docker container:
docker run -d --env-file .env -v $(pwd)/attachments:/attachments imap-attachment-daemon
You can also run the project using docker-compose
:
-
Start the service using Docker Compose:
docker-compose up -d
Contributions are welcome! Please follow these steps to set up your development environment:
-
Install
pre-commit
:pip install pre-commit pre-commit install
-
Install
cargo-nextest
:cargo install cargo-nextest
Please open an issue or submit a pull request for any contributions.
This project is licensed under the MIT License. See the LICENSE file for details.
For any inquiries, please email me.