Initial commit: Mail service with Brevo SMTP
- Express server with REST API for sending emails - SQLite database for persistent email history - Web interface with form (recipient, CC, subject, text/HTML) - Email footer with embedded image (CID attachment) - Nodemailer configured for Brevo SMTP relay Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
104
docs/plans/2026-01-16-mail-service-design.md
Normal file
104
docs/plans/2026-01-16-mail-service-design.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# Mail-Service Design
|
||||
|
||||
**Datum:** 2026-01-16
|
||||
**Status:** Genehmigt
|
||||
|
||||
## Übersicht
|
||||
|
||||
Weboberfläche zum Testen des Mail-Versands über Brevo (SMTP). Node.js-basiert mit persistenter Historie.
|
||||
|
||||
## Technologie-Stack
|
||||
|
||||
- **Backend:** Node.js, Express
|
||||
- **Mail:** Nodemailer
|
||||
- **Datenbank:** SQLite (better-sqlite3)
|
||||
- **Frontend:** HTML, CSS, Vanilla JS
|
||||
|
||||
## Projektstruktur
|
||||
|
||||
```
|
||||
mail-service/
|
||||
├── .env # Konfiguration (SMTP, Port)
|
||||
├── .env.example # Vorlage ohne sensible Daten
|
||||
├── package.json
|
||||
├── src/
|
||||
│ ├── server.js # Express-Server, Routen
|
||||
│ ├── mailer.js # Nodemailer-Konfiguration
|
||||
│ └── database.js # SQLite-Setup und Queries
|
||||
├── public/
|
||||
│ ├── index.html # Hauptseite mit Formular
|
||||
│ ├── style.css # Styling
|
||||
│ └── script.js # Frontend-Logik
|
||||
└── data/
|
||||
└── emails.db # SQLite-Datenbank
|
||||
```
|
||||
|
||||
## Datenbank-Schema
|
||||
|
||||
**Tabelle `emails`:**
|
||||
|
||||
| Spalte | Typ | Beschreibung |
|
||||
|--------|-----|--------------|
|
||||
| id | INTEGER | Primary Key, Auto-Increment |
|
||||
| to_email | TEXT | Empfänger-Adresse |
|
||||
| cc_email | TEXT | CC-Adresse (optional) |
|
||||
| subject | TEXT | Betreff |
|
||||
| body | TEXT | Nachrichteninhalt |
|
||||
| is_html | INTEGER | 0 = Text, 1 = HTML |
|
||||
| status | TEXT | "success" oder "failed" |
|
||||
| error_message | TEXT | Fehlermeldung falls fehlgeschlagen |
|
||||
| created_at | TEXT | ISO-Timestamp |
|
||||
|
||||
## API-Endpunkte
|
||||
|
||||
| Methode | Route | Beschreibung |
|
||||
|---------|-------|--------------|
|
||||
| GET | `/` | Weboberfläche (index.html) |
|
||||
| POST | `/api/send` | Mail versenden |
|
||||
| GET | `/api/history` | Historie abrufen (letzte 50) |
|
||||
| DELETE | `/api/history/:id` | Einzelnen Eintrag löschen |
|
||||
| DELETE | `/api/history` | Gesamte Historie löschen |
|
||||
|
||||
## Weboberfläche
|
||||
|
||||
Zweispaltiges Layout:
|
||||
- **Links:** Mail-Formular (Empfänger, CC, Betreff, Text/HTML-Toggle, Nachricht)
|
||||
- **Rechts:** Versand-Historie mit Status-Icons und Lösch-Buttons
|
||||
|
||||
## Fehlerbehandlung
|
||||
|
||||
| Fehlertyp | Behandlung |
|
||||
|-----------|------------|
|
||||
| Ungültige E-Mail-Adresse | Validierung Frontend + Backend |
|
||||
| SMTP-Verbindungsfehler | In DB als "failed" speichern |
|
||||
| Authentifizierungsfehler | Hinweis auf .env-Konfiguration |
|
||||
| Timeout | Nach 30 Sekunden Abbruch |
|
||||
| Leere Pflichtfelder | Frontend verhindert Absenden |
|
||||
|
||||
## Konfiguration (.env)
|
||||
|
||||
```env
|
||||
# Server
|
||||
PORT=3000
|
||||
|
||||
# Email Configuration
|
||||
MAIL_PROVIDER=smtp
|
||||
MAIL_FROM_EMAIL=noreply@businesshelpdesk.biz
|
||||
MAIL_FROM_NAME=Secure Portal
|
||||
|
||||
# SMTP (Brevo)
|
||||
SMTP_HOST=smtp-relay.brevo.com
|
||||
SMTP_PORT=587
|
||||
SMTP_USER=<user>
|
||||
SMTP_PASSWORD=<password>
|
||||
SMTP_SECURE=false
|
||||
```
|
||||
|
||||
## Ausführung
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
Server läuft auf http://localhost:3000
|
||||
Reference in New Issue
Block a user