SMTP settings on the Settings page, with a test (1.2.0)

SMTP server, port, user, password and from address are now Hub settings in
the database instead of SMTP_* in .env. The password is encrypted with
HUB_ENCRYPTION_KEY and never sent to the browser; a blank field keeps it.
POST /api/admin/settings/smtp-test logs in with the form's values (saved or
not) and sends a test email, returning the server's reason on failure; it is
rate limited and audited. On first start an existing SMTP_* setup is copied
into Settings once. The audit log no longer records the SMTP password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls1vMaqhrehXcHJe32jLL9
This commit is contained in:
2026-10-28 01:26:41 +02:00
co-authored by Claude Opus 5.5
parent ad01328ce3
commit 613a4450cb
13 changed files with 298 additions and 35 deletions
+6
View File
@@ -10,6 +10,7 @@ if (missing.length) {
const app = require('./app');
const { keyPair } = require('./utils/licenceToken');
const { runAlerts, rollupHeartbeats } = require('./utils/alerts');
const { importSmtpFromEnv } = require('./utils/settings');
// Fail early if the licence signing key is missing or wrong.
try {
@@ -19,6 +20,11 @@ try {
process.exit(1);
}
// SMTP moved from .env to the Settings page in 1.2.0; carry the old values over once.
importSmtpFromEnv()
.then(done => { if (done) console.log('[hub] Copied SMTP_* from .env to Settings. You can remove them from .env now.'); })
.catch(e => console.warn('[hub] Could not copy SMTP_* from .env:', e?.message || e));
const PORT = parseInt(process.env.PORT || '5200', 10);
app.listen(PORT, () => console.log(`[hub] Listening on ${PORT}`));