No description
|
All checks were successful
Build and Push Mail2NC / Load Configuration (push) Successful in 2s
Build and Push Mail2NC / Build (push) Successful in 41s
Build and Push Mail2NC / Functional Tests (push) Successful in 7s
Build and Push Mail2NC / Compliance Scan (push) Successful in 47s
Build and Push Mail2NC / Security Scan (push) Successful in 1m0s
Build and Push Mail2NC / Push to Production (push) Successful in 7s
Build and Push Mail2NC / Cleanup (push) Successful in 1s
|
||
|---|---|---|
| .github/workflows | ||
| examples | ||
| .dockerignore | ||
| .gitignore | ||
| .metadata.json | ||
| Dockerfile | ||
| main.py | ||
| README.md | ||
Mail2NC
Polls an IMAP mailbox and uploads attachments to Nextcloud via WebDAV.
Quick Start
services:
mail2nc:
image: git.breis.ch/clement/mail2nc:latest
environment:
IMAP_HOST: mail.example.com
IMAP_USER: scanner@example.com
IMAP_PASS: secret
NEXTCLOUD_URL: https://cloud.example.com
NEXTCLOUD_USER: admin
NEXTCLOUD_PASS: secret
volumes:
- mail2nc-data:/data
volumes:
mail2nc-data:
For a production setup with Docker secrets and full security hardening, see examples/docker-compose.yml.
Environment Variables
Required
| Variable | Description |
|---|---|
IMAP_HOST |
IMAP server hostname |
IMAP_USER |
IMAP login username |
IMAP_PASS |
IMAP login password |
NEXTCLOUD_URL |
Nextcloud base URL (e.g. https://cloud.example.com) |
NEXTCLOUD_USER |
Nextcloud username for WebDAV uploads |
NEXTCLOUD_PASS |
Nextcloud password or app token |
Optional
| Variable | Default | Description |
|---|---|---|
IMAP_PORT |
993 |
IMAP SSL port |
IMAP_FOLDER |
INBOX |
IMAP folder to monitor |
NEXTCLOUD_FOLDER |
/Scans |
Nextcloud destination folder |
POLL_INTERVAL |
30 |
Seconds between mailbox checks |
Docker Secrets
All variables support the _FILE suffix for Docker secrets. When set, the value is read from the file path provided.
secrets:
imap_password:
file: ./secrets/imap_password.txt
services:
mail2nc:
environment:
IMAP_PASS_FILE: /run/secrets/imap_password
secrets:
- imap_password
How It Works
- Connects to the IMAP server over SSL
- Searches for new/unseen emails
- Extracts attachments from each email
- Uploads them to Nextcloud via WebDAV with sanitized filenames
- Marks successfully processed emails as read
- Persists state to
/data/state.jsonto survive restarts
Filenames follow the pattern: YYYYMMDD_HHMMSS_uid<N>_<original_name>
If an upload fails, the email is not marked as read and will be retried on the next poll.
Persistence
Mount a volume at /data to persist the processing state across container restarts. Without it, previously processed emails may be re-uploaded.