131 lines
3.5 KiB
Markdown
131 lines
3.5 KiB
Markdown
|
|
# MailPrint
|
|||
|
|
|
|||
|
|
**Windows-Dienst zum automatischen Drucken von PDF-Anhängen aus E-Mails, per REST API und per Ordner-Überwachung.**
|
|||
|
|
|
|||
|
|
Kostenlos und quelloffen. Version 1.0.0
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## Features
|
|||
|
|
|
|||
|
|
- 📧 **IMAP / POP3** – Postfächer werden automatisch abgerufen, PDF-Anhänge sofort gedruckt
|
|||
|
|
- 📂 **Ordner-Überwachung** – PDFs in überwachten Ordnern werden automatisch gedruckt
|
|||
|
|
- 🖨️ **Mehrere Drucker-Profile** – je Profil eigener Drucker, Papierfach, Duplex 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
|
|||
|
|
- ↔️ **Duplex-Druck** – einseitig, lange Seite oder kurze Seite
|
|||
|
|
- ✉️ **E-Mail-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
|