All checks were successful
Build and Push Docker Images / build-frontend (push) Successful in 24s
Build and Push Docker Images / build-website (push) Successful in 22s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-central-services-admin (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 1m23s
Build and Push Docker Images / build-backend (push) Successful in 29s
63 lines
2.1 KiB
Markdown
63 lines
2.1 KiB
Markdown
# Gmail-Anhänge herunterladen
|
|
|
|
Das Skript `scripts/download-gmail-attachments.py` lädt Anhänge aus einem Gmail-Postfach per IMAP herunter. Es nutzt nur Python-Standardbibliotheken.
|
|
|
|
## Voraussetzungen
|
|
|
|
- IMAP muss im Gmail-Konto aktiviert sein.
|
|
- Für Konten mit Zwei-Faktor-Authentifizierung wird ein Gmail App-Passwort benötigt.
|
|
- Python 3.9 oder neuer.
|
|
|
|
## Beispiele
|
|
|
|
Alle Anhänge aus dem kompletten Gmail-Postfach herunterladen:
|
|
|
|
```bash
|
|
GMAIL_APP_PASSWORD="dein-app-passwort" \
|
|
python3 scripts/download-gmail-attachments.py \
|
|
--email name@gmail.com \
|
|
--output gmail-anhaenge \
|
|
--group-by-message \
|
|
--debug
|
|
```
|
|
|
|
Nur Anhänge ab einem bestimmten Datum herunterladen:
|
|
|
|
```bash
|
|
GMAIL_APP_PASSWORD="dein-app-passwort" \
|
|
python3 scripts/download-gmail-attachments.py \
|
|
--email name@gmail.com \
|
|
--since 2026-01-01 \
|
|
--output gmail-anhaenge
|
|
```
|
|
|
|
Nur ungelesene Mails durchsuchen:
|
|
|
|
```bash
|
|
GMAIL_APP_PASSWORD="dein-app-passwort" \
|
|
python3 scripts/download-gmail-attachments.py \
|
|
--email name@gmail.com \
|
|
--search UNSEEN
|
|
```
|
|
|
|
Verfügbare IMAP-Postfächer anzeigen, falls `[Gmail]/All Mail` nicht passt:
|
|
|
|
```bash
|
|
GMAIL_APP_PASSWORD="dein-app-passwort" \
|
|
python3 scripts/download-gmail-attachments.py \
|
|
--email name@gmail.com \
|
|
--list-mailboxes
|
|
```
|
|
|
|
Wenn `--password` nicht gesetzt ist und `GMAIL_APP_PASSWORD` fehlt, fragt das Skript das Passwort interaktiv ab. Mit `--debug` zeigt das Skript unter anderem den Aufbau der TLS-Verbindung, den erfolgreichen Login, das ausgewählte Postfach, die Suche und die Verarbeitung jeder Mail an. Das Passwort selbst wird nie ausgegeben.
|
|
|
|
## Häufige Optionen
|
|
|
|
- Ohne `--mailbox` erkennt das Skript das sprachabhängige Gmail-Postfach für alle Nachrichten automatisch.
|
|
- `--mailbox "Postfachname"` überschreibt die automatische Auswahl.
|
|
- `--list-mailboxes` zeigt alle verfügbaren Gmail-IMAP-Postfächer an.
|
|
- `--debug` aktiviert detaillierte Statusausgaben inklusive Login-Erfolg.
|
|
- `--group-by-message` legt pro Mail einen Unterordner an.
|
|
- `--overwrite` überschreibt vorhandene Dateien.
|
|
- `--since YYYY-MM-DD` und `--before YYYY-MM-DD` grenzen den Zeitraum ein.
|