MailPrint/README.md

128 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# MailPrint
**Windows-Dienst zum automatischen Drucken von PDF-Anhängen aus E-Mails und per REST API.**
Kostenlos und quelloffen.
---
## Features
- 📧 **IMAP / POP3** Postfächer werden automatisch abgerufen, PDF-Anhänge sofort gedruckt
- 🖨️ **Mehrere Drucker-Profile** je Profil eigener Drucker, Papierfach und Kopienanzahl
- 📬 **Mehrere Postfächer** jedes Postfach zeigt auf ein Drucker-Profil
- 🌐 **REST API** PDF per HTTP-Upload oder URL drucken (z.B. aus einem Webshop)
- 🔒 **API-Key Absicherung** optionaler Schutz für den HTTP-Endpunkt
- 🗂️ **Papierfach-Steuerung** SumatraPDF-basiert, stiller Druck ohne Fenster
- ✉️ **Whitelist / Blacklist** global und pro Drucker-Profil
- ⚙️ **Config-Tool** WinForms GUI zum Konfigurieren ohne JSON-Bearbeitung
- 🔄 **Windows Service** läuft ohne Anmeldung im Hintergrund
---
## Voraussetzungen
- Windows 10 / Server 2019 oder neuer
- [.NET 10 Runtime (Windows)](https://dotnet.microsoft.com/download/dotnet/10.0)
- [SumatraPDF](https://www.sumatrapdfreader.org/download-free-pdf-viewer) (wird automatisch erkannt wenn installiert oder neben der EXE)
- Installierter Windows-Drucker
---
## Installation
### 1. Release entpacken
Inhalt des `publish`-Ordners in ein Zielverzeichnis kopieren, z.B.:
```
C:\Services\MailPrint\
```
### 2. Konfigurieren
`MailPrintConfig.exe` starten und konfigurieren:
- **Drucker-Profile** Drucker + Papierfach + optionale Absender-Filter
- **Postfächer** IMAP/POP3 Zugangsdaten + zugeordnetes Drucker-Profil
- **Web API** Port, API-Key, FritzBox-Portmapping
- **Filter** globale Whitelist/Blacklist
- **Allgemein** Intervall, SumatraPDF-Pfad, Temp-Verzeichnis
Auf **Speichern** klicken.
### 3. Als Windows Service installieren
```powershell
# Als Administrator ausführen:
.\install-service.ps1
```
### 4. Deinstallieren
```powershell
# Als Administrator ausführen:
.\uninstall-service.ps1
```
---
## Web API
| Methode | Endpunkt | Beschreibung |
|---|---|---|
| `POST` | `/api/print/upload` | PDF hochladen (multipart/form-data) |
| `POST` | `/api/print/url` | PDF-URL übergeben |
| `GET` | `/api/print/printers` | Drucker + Papierfächer auflesen |
| `GET` | `/api/print/health` | Healthcheck |
| `GET` | `/swagger` | Swagger UI |
### Authentifizierung
```http
X-Api-Key: <dein-api-key>
```
### Beispiel Upload (curl)
```bash
curl -X POST http://localhost:5100/api/print/upload \
-H "X-Api-Key: DEIN_KEY" \
-F "file=@rechnung.pdf" \
-F "printer=HP LaserJet" \
-F "paperSource=Fach 2" \
-F "copies=1"
```
### Beispiel URL (PowerShell)
```powershell
Invoke-RestMethod -Uri "http://localhost:5100/api/print/url" `
-Method Post `
-Headers @{"X-Api-Key" = "DEIN_KEY"; "Content-Type" = "application/json"} `
-Body '{"url":"https://example.com/rechnung.pdf","copies":1}'
```
---
## Papierfach-Steuerung
SumatraPDF wird automatisch gefunden wenn:
- Installiert unter `C:\Program Files\SumatraPDF\`
- Installiert unter `%LOCALAPPDATA%\SumatraPDF\`
- `SumatraPDF.exe` liegt neben `MailPrint.exe`
Ohne SumatraPDF: Fallback auf Windows Shell-Print (kein Papierfach-Support).
---
## Logs
- Konsole (wenn als EXE gestartet)
- `logs\mailprint-YYYYMMDD.log` (neben der EXE)
- Windows EventLog unter „MailPrint" (wenn als Service)
---
## Lizenz
MIT