Automatischer PDF-Druck per E-Mail und REST API
Find a file
2026-04-17 00:00:31 +02:00
MailPrint Add .gitignore, remove build artifacts and secrets 2026-04-17 00:00:31 +02:00
MailPrintConfig Add .gitignore, remove build artifacts and secrets 2026-04-17 00:00:31 +02:00
.gitignore Add .gitignore, remove build artifacts and secrets 2026-04-17 00:00:31 +02:00
build.bat Initial commit 2026-04-17 00:00:02 +02:00
MailPrint.sln Initial commit 2026-04-17 00:00:02 +02:00
README.md Initial commit 2026-04-17 00:00:02 +02:00

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


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

# Als Administrator ausführen:
.\install-service.ps1

4. Deinstallieren

# 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

X-Api-Key: <dein-api-key>

Beispiel Upload (curl)

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)

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}'

FritzBox Portmapping

FritzBox → Heimnetz → Netzwerk → Portfreigaben:

  • Protokoll: TCP
  • Externer Port: z.B. 5100
  • Interner Host: IP des Windows-PCs
  • Interner Port: 5100

In appsettings.json bzw. Config-Tool: BindAllInterfaces: true setzen.


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